Rack::JWT
This gem provides JSON Web Token (JWT) based authentication.
Installation
Add this line to your application's Gemfile:
gem 'rack-jwt'
And then execute:
$ bundle
Or install it yourself as:
$ gem install rack-jwt
Usage
sinatra
use Rack::JWT::Auth secret: 'you_secret_token_goes_here', exclude: ['/api/docs']
Rails
Rails.application.config.middleware.use, Rack::JWT::Auth, secret: Rails.application.secrets.secret_key_base, exclude: ['/api/docs']
Generating tokens
You can generate JSON Wen Tokens for your users using the Token#encode
method
Rack::JWT::Token.encode(payload, secret)
Contributing
- Fork it ( https://github.com/[my-github-username]/rack-jwt/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request