An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

README

          

# Rack::JWT

[![Gem Version](https://badge.fury.io/rb/rack-jwt.svg)](http://badge.fury.io/rb/rack-jwt)
[![Build Status](https://travis-ci.org/eigenbart/rack-jwt.svg)](https://travis-ci.org/eigenbart/rack-jwt)
[![Code Climate](https://codeclimate.com/github/eigenbart/rack-jwt/badges/gpa.svg)](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