JWT User Authorization Middleware
Add the following to any params that require authorization. The tokenParam must match the name of the user_id in the jwt, not the route param.
var auth = ; router;
To generate a jwt token in Ruby.
JWT.encode({"id" => 1}, "secret") => "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCciOjg5fQ.wUlU3JFv-wQYPfa9NRwh06wJWcOtYErRN23iTvMPTIE"
Examples using curl
curl -X GET -H "Authorization:Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCciOjg5fQ.wUlU3JFv-wQYPfa9NRwh06wJWcOtYErRN23iTvMPTIE" -H "Cache-Control:no-cache" http://localhost:2014/users/1
Or
curl -X GET http://localhost:2014/users/1&authorization=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCciOjg5fQ.wUlU3JFv-wQYPfa9NRwh06wJWcOtYErRN23iTvMPTIE
From jquery
$
Or
$