https://github.com/fgrehm/rack-jwt
Rack middleware that provides authentication based on JSON Web Tokens
https://github.com/fgrehm/rack-jwt
Last synced: 10 months ago
JSON representation
Rack middleware that provides authentication based on JSON Web Tokens
- Host: GitHub
- URL: https://github.com/fgrehm/rack-jwt
- Owner: fgrehm
- License: mit
- Created: 2015-06-09T18:34:32.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2015-06-09T18:59:02.000Z (about 11 years ago)
- Last Synced: 2023-04-10T09:40:03.097Z (about 3 years ago)
- Language: Ruby
- Size: 84 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Rack::JWT
[](http://badge.fury.io/rb/rack-jwt)
[](https://travis-ci.org/eigenbart/rack-jwt)
[](https://codeclimate.com/github/eigenbart/rack-jwt)
This gem provides JSON Web Token (JWT) based authentication.
## Installation
Add this line to your application's Gemfile:
```ruby
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
1. Fork it ( https://github.com/[my-github-username]/rack-jwt/fork )
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request