README.md in doorkeeper-jwt-0.2.1 vs README.md in doorkeeper-jwt-0.3.0
- old
+ new
@@ -1,12 +1,13 @@
-[![Coverage Status](https://coveralls.io/repos/chriswarren/doorkeeper-jwt/badge.svg?branch=master)](https://coveralls.io/r/chriswarren/doorkeeper-jwt?branch=master)
-[![Build Status](https://travis-ci.org/chriswarren/doorkeeper-jwt.svg?branch=master)](https://travis-ci.org/chriswarren/doorkeeper-jwt)
-[![Code Climate](https://codeclimate.com/github/chriswarren/doorkeeper-jwt/badges/gpa.svg)](https://codeclimate.com/github/chriswarren/doorkeeper-jwt)
+[![Coverage Status](https://coveralls.io/repos/github/doorkeeper-gem/doorkeeper-jwt/badge.svg?branch=master)](https://coveralls.io/github/doorkeeper-gem/doorkeeper-jwt?branch=master)
+[![Build Status](https://travis-ci.org/doorkeeper-gem/doorkeeper-jwt.svg?branch=master)](https://travis-ci.org/doorkeeper-gem/doorkeeper-jwt)
+[![Maintainability](https://api.codeclimate.com/v1/badges/ca4d81b49acabda27e0c/maintainability)](https://codeclimate.com/github/doorkeeper-gem/doorkeeper-jwt/maintainability)
# Doorkeeper::JWT
-Doorkeeper JWT adds JWT token support to the Doorkeeper OAuth library. Requires Doorkeeper 2.2.0 or newer.
+Doorkeeper JWT adds JWT token support to the Doorkeeper OAuth library. Confirmed to work with Doorkeeper 2.2.x - 4.x.
+Untested with later versions of Doorkeeper.
```ruby
gem 'doorkeeper'
```
@@ -29,11 +30,11 @@
## Usage
In your `doorkeeper.rb` initializer add the follow to the `Doorkeeper.configure` block:
```ruby
-access_token_generator "Doorkeeper::JWT"
+access_token_generator '::Doorkeeper::JWT'
```
Then add a `Doorkeeper::JWT.configure` block below the `Doorkeeper.configure` block to set your JWT preferences.
```ruby
@@ -44,10 +45,14 @@
# { token: "RANDOM-TOKEN" }
token_payload do |opts|
user = User.find(opts[:resource_owner_id])
{
+ iss: 'My App',
+ iat: Time.current.utc.to_i,
+ jti: SecureRandom.uuid, # @see JWT reserved claims - https://tools.ietf.org/html/draft-jones-json-web-token-07#page-7
+
user: {
id: user.id,
email: user.email
}
}
@@ -66,28 +71,31 @@
use_application_secret false
# Set the encryption secret. This would be shared with any other applications
# that should be able to read the payload of the token.
# Defaults to "secret"
- secret_key "MY-SECRET"
+ secret_key ENV['JWT_SECRET']
# If you want to use RS* encoding specify the path to the RSA key
# to use for signing.
# If you specify a secret_key_path it will be used instead of secret_key
- secret_key_path "path/to/file.pem"
+ secret_key_path File.join('path', 'to', 'file.pem')
- # Specify encryption type. Supports any algorithim in
+ # Specify encryption type. Supports any algorithm in
# https://github.com/progrium/ruby-jwt
# defaults to nil
encryption_method :hs512
end
```
## Development
-After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
+After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive
+prompt that will allow you to experiment.
-To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
+To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update
+the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the
+version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
## Contributing
1. Fork it ( https://github.com/[my-github-username]/doorkeeper-jwt/fork )
2. Create your feature branch (`git checkout -b my-new-feature`)