doorkeeper-jwt 0.3.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/dependabot.yml +7 -0
- data/.github/workflows/ci.yml +38 -0
- data/.gitignore +12 -6
- data/.hound.yml +3 -0
- data/.rubocop.yml +52 -3
- data/CHANGELOG.md +20 -4
- data/Gemfile +6 -2
- data/README.md +24 -25
- data/Rakefile +2 -0
- data/bin/console +4 -1
- data/bin/setup +3 -2
- data/doorkeeper-jwt.gemspec +21 -17
- data/lib/{doorkeeper-jwt → doorkeeper/jwt}/config.rb +44 -44
- data/lib/{doorkeeper-jwt → doorkeeper/jwt}/version.rb +3 -3
- data/lib/{doorkeeper-jwt.rb → doorkeeper/jwt.rb} +29 -12
- metadata +24 -41
- data/.travis.yml +0 -6
- data/lib/doorkeeper-jwt/doorkeeper-jwt.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e221c6342513368dcb299a24749a66fe45936fd1eef1ab3e93d1b34b7d0a89ca
|
4
|
+
data.tar.gz: 976256cc0a811b02e0ae9738842f99a8ccc57a054f8adea6fce9072db40cc390
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca803cc8cff761b4c2e7eddeeb2bf673ff3c4b32bdad377149904504c4d4dcc411dbe7bdfac7ac87f7deebe6e61a309ca983eb42c348e904265b3086311eccb3
|
7
|
+
data.tar.gz: e4c2690b4ddc8d0ace06d44659a7a91480f452394e8a6f7781c4dc4cd057101d38968559751ee15abcacf1ccdb49da05ad80a4ff0efd4c4c90527b013c35bffd
|
@@ -0,0 +1,38 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on: [push, pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
name: >-
|
8
|
+
Ruby ${{ matrix.ruby }}
|
9
|
+
env:
|
10
|
+
CI: true
|
11
|
+
runs-on: ${{ matrix.os }}
|
12
|
+
continue-on-error: ${{ endsWith(matrix.ruby, 'head') || matrix.ruby == 'debug' || matrix.experimental }}
|
13
|
+
if: |
|
14
|
+
!( contains(github.event.pull_request.title, '[ci skip]')
|
15
|
+
|| contains(github.event.pull_request.title, '[skip ci]'))
|
16
|
+
strategy:
|
17
|
+
fail-fast: true
|
18
|
+
matrix:
|
19
|
+
experimental: [false]
|
20
|
+
os: [ ubuntu-latest ]
|
21
|
+
ruby:
|
22
|
+
- 2.6
|
23
|
+
- 2.7
|
24
|
+
- '3.0'
|
25
|
+
- '3.1'
|
26
|
+
steps:
|
27
|
+
- name: Repo checkout
|
28
|
+
uses: actions/checkout@v2
|
29
|
+
|
30
|
+
- name: Setup Ruby
|
31
|
+
uses: ruby/setup-ruby@v1
|
32
|
+
with:
|
33
|
+
ruby-version: ${{ matrix.ruby }}
|
34
|
+
bundler-cache: true
|
35
|
+
|
36
|
+
- name: Run tests
|
37
|
+
timeout-minutes: 10
|
38
|
+
run: bundle exec rake test
|
data/.gitignore
CHANGED
data/.hound.yml
ADDED
data/.rubocop.yml
CHANGED
@@ -1,13 +1,62 @@
|
|
1
|
+
---
|
2
|
+
require: rubocop-rspec
|
3
|
+
|
4
|
+
AllCops:
|
5
|
+
DefaultFormatter: progress
|
6
|
+
DisplayCopNames: true
|
7
|
+
DisplayStyleGuide: false
|
8
|
+
ExtraDetails: true
|
9
|
+
TargetRubyVersion: 2.5
|
10
|
+
|
11
|
+
Metrics/LineLength:
|
12
|
+
Exclude:
|
13
|
+
- spec/**/*
|
14
|
+
Max: 100
|
15
|
+
|
1
16
|
Metrics/BlockLength:
|
2
17
|
Exclude:
|
3
18
|
- spec/**/*
|
19
|
+
- doorkeeper-jwt.gemspec
|
20
|
+
|
21
|
+
Style/StringLiterals:
|
22
|
+
EnforcedStyle: double_quotes
|
23
|
+
Style/StringLiteralsInInterpolation:
|
24
|
+
EnforcedStyle: double_quotes
|
25
|
+
|
26
|
+
Style/FrozenStringLiteralComment:
|
27
|
+
Enabled: true
|
4
28
|
|
5
|
-
|
29
|
+
Style/TrailingCommaInHashLiteral:
|
30
|
+
EnforcedStyleForMultiline: consistent_comma
|
31
|
+
Style/TrailingCommaInArrayLiteral:
|
32
|
+
EnforcedStyleForMultiline: consistent_comma
|
33
|
+
|
34
|
+
Style/SymbolArray:
|
35
|
+
MinSize: 3
|
36
|
+
Style/WordArray:
|
37
|
+
MinSize: 3
|
38
|
+
|
39
|
+
Style/ClassAndModuleChildren:
|
6
40
|
Exclude:
|
7
41
|
- spec/**/*
|
42
|
+
Style/NumericPredicate:
|
43
|
+
Enabled: false
|
44
|
+
Style/DoubleNegation:
|
45
|
+
Enabled: false
|
46
|
+
|
47
|
+
Layout/MultilineMethodCallIndentation:
|
48
|
+
EnforcedStyle: indented
|
49
|
+
Layout/TrailingBlankLines:
|
50
|
+
Enabled: true
|
51
|
+
Layout/DotPosition:
|
52
|
+
EnforcedStyle: leading
|
53
|
+
|
54
|
+
Naming/FileName:
|
55
|
+
Exclude:
|
56
|
+
- lib/doorkeeper-jwt.rb
|
8
57
|
|
9
|
-
|
58
|
+
RSpec/ExampleLength:
|
10
59
|
Enabled: false
|
11
60
|
|
12
|
-
|
61
|
+
RSpec/MultipleExpectations:
|
13
62
|
Enabled: false
|
data/CHANGELOG.md
CHANGED
@@ -1,14 +1,29 @@
|
|
1
1
|
# Change Log
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
|
4
|
-
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
5
|
-
|
4
|
+
The format is based on [Keep a Changelog](http://keepachangelog.com/) and this
|
5
|
+
project adheres to [Semantic Versioning](http://semver.org/).
|
6
|
+
|
7
|
+
## master
|
8
|
+
|
9
|
+
### Changed
|
10
|
+
|
11
|
+
## [0.4.1] - 2022-02-23
|
12
|
+
|
13
|
+
- JWT gem requirement relaxed to use any version >= 2.1
|
14
|
+
|
15
|
+
### Changed
|
16
|
+
|
17
|
+
## [0.4.0] - 2019-10-02
|
18
|
+
|
19
|
+
- Restructured library files to follow naming conventions. (https://guides.rubygems.org/name-your-gem/).
|
20
|
+
- Add support of new doorkeeper with encryption [#30](https://github.com/doorkeeper-gem/doorkeeper-jwt/pull/30)
|
6
21
|
|
7
22
|
## [0.3.0] - 2018-10-01
|
8
23
|
|
9
24
|
### Added
|
10
25
|
|
11
|
-
- Bump JWT gem version. Via [#27](https://github.com/doorkeeper-gem/doorkeeper-jwt/pull/27) by [@pacop](https://github.com/pacop/)
|
26
|
+
- Bump JWT gem version. Via [#27](https://github.com/doorkeeper-gem/doorkeeper-jwt/pull/27) by [@pacop](https://github.com/pacop/).
|
12
27
|
|
13
28
|
## [0.2.1] - 2017-06-07
|
14
29
|
|
@@ -20,4 +35,5 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|
20
35
|
|
21
36
|
### Added
|
22
37
|
|
23
|
-
- Added support for ["kid" (Key ID) Header Parameter](https://tools.ietf.org/html/rfc7515#section-4.1.4)
|
38
|
+
- Added support for ["kid" (Key ID) Header Parameter](https://tools.ietf.org/html/rfc7515#section-4.1.4)
|
39
|
+
@travisofthenorth. Allows custom token headers.
|
data/Gemfile
CHANGED
@@ -1,6 +1,10 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
2
4
|
|
3
5
|
# Specify your gem's dependencies in doorkeeper-jwt.gemspec
|
4
6
|
gemspec
|
5
7
|
|
6
|
-
gem
|
8
|
+
gem "coveralls", require: false
|
9
|
+
gem "rubocop", "~> 1.8", require: false
|
10
|
+
gem "rubocop-rspec", "~> 2.1", require: false
|
data/README.md
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
[![Gem Version](https://badge.fury.io/rb/doorkeeper-jwt.svg)](https://rubygems.org/gems/doorkeeper-jwt)
|
1
2
|
[![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)
|
2
3
|
[![Build Status](https://travis-ci.org/doorkeeper-gem/doorkeeper-jwt.svg?branch=master)](https://travis-ci.org/doorkeeper-gem/doorkeeper-jwt)
|
3
4
|
[![Maintainability](https://api.codeclimate.com/v1/badges/ca4d81b49acabda27e0c/maintainability)](https://codeclimate.com/github/doorkeeper-gem/doorkeeper-jwt/maintainability)
|
@@ -40,16 +41,17 @@ Then add a `Doorkeeper::JWT.configure` block below the `Doorkeeper.configure` bl
|
|
40
41
|
```ruby
|
41
42
|
Doorkeeper::JWT.configure do
|
42
43
|
# Set the payload for the JWT token. This should contain unique information
|
43
|
-
# about the user.
|
44
|
-
#
|
45
|
-
# { token: "RANDOM-TOKEN" }
|
44
|
+
# about the user. Defaults to a randomly generated token in a hash:
|
45
|
+
# { token: "RANDOM-TOKEN" }
|
46
46
|
token_payload do |opts|
|
47
47
|
user = User.find(opts[:resource_owner_id])
|
48
48
|
|
49
49
|
{
|
50
50
|
iss: 'My App',
|
51
51
|
iat: Time.current.utc.to_i,
|
52
|
-
|
52
|
+
|
53
|
+
# @see JWT reserved claims - https://tools.ietf.org/html/draft-jones-json-web-token-07#page-7
|
54
|
+
jti: SecureRandom.uuid,
|
53
55
|
|
54
56
|
user: {
|
55
57
|
id: user.id,
|
@@ -58,47 +60,44 @@ Doorkeeper::JWT.configure do
|
|
58
60
|
}
|
59
61
|
end
|
60
62
|
|
61
|
-
# Optionally set additional headers for the JWT. See
|
63
|
+
# Optionally set additional headers for the JWT. See
|
64
|
+
# https://tools.ietf.org/html/rfc7515#section-4.1
|
62
65
|
token_headers do |opts|
|
63
|
-
{
|
64
|
-
kid: opts[:application][:uid]
|
65
|
-
}
|
66
|
+
{ kid: opts[:application][:uid] }
|
66
67
|
end
|
67
68
|
|
68
|
-
# Use the application secret specified in the
|
69
|
-
#
|
70
|
-
#
|
69
|
+
# Use the application secret specified in the access grant token. Defaults to
|
70
|
+
# `false`. If you specify `use_application_secret true`, both `secret_key` and
|
71
|
+
# `secret_key_path` will be ignored.
|
71
72
|
use_application_secret false
|
72
73
|
|
73
74
|
# Set the encryption secret. This would be shared with any other applications
|
74
|
-
# that should be able to read the payload of the token.
|
75
|
-
# Defaults to "secret"
|
75
|
+
# that should be able to read the payload of the token. Defaults to "secret".
|
76
76
|
secret_key ENV['JWT_SECRET']
|
77
77
|
|
78
|
-
# If you want to use RS* encoding specify the path to the RSA key
|
79
|
-
#
|
80
|
-
#
|
78
|
+
# If you want to use RS* encoding specify the path to the RSA key to use for
|
79
|
+
# signing. If you specify a `secret_key_path` it will be used instead of
|
80
|
+
# `secret_key`.
|
81
81
|
secret_key_path File.join('path', 'to', 'file.pem')
|
82
82
|
|
83
|
-
# Specify encryption type.
|
84
|
-
#
|
85
|
-
# defaults to nil
|
83
|
+
# Specify encryption type (https://github.com/progrium/ruby-jwt). Defaults to
|
84
|
+
# `nil`.
|
86
85
|
encryption_method :hs512
|
87
86
|
end
|
88
87
|
```
|
89
88
|
|
90
89
|
## Development
|
91
90
|
|
92
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive
|
93
|
-
|
91
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt
|
92
|
+
that will allow you to experiment.
|
94
93
|
|
95
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update
|
96
|
-
|
97
|
-
|
94
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the
|
95
|
+
version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git
|
96
|
+
commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
98
97
|
|
99
98
|
## Contributing
|
100
99
|
|
101
|
-
1. Fork it (
|
100
|
+
1. Fork it (https://github.com/[my-github-username]/doorkeeper-jwt/fork)
|
102
101
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
103
102
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
104
103
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/Rakefile
CHANGED
data/bin/console
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
require "bundler/setup"
|
4
5
|
require "doorkeeper-jwt"
|
@@ -7,8 +8,10 @@ require "doorkeeper-jwt"
|
|
7
8
|
# with your gem easier. You can also use a different console, if you like.
|
8
9
|
|
9
10
|
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require
|
11
|
+
# require 'pry'
|
12
|
+
#
|
11
13
|
# Pry.start
|
12
14
|
|
13
15
|
require "irb"
|
16
|
+
|
14
17
|
IRB.start
|
data/bin/setup
CHANGED
data/doorkeeper-jwt.gemspec
CHANGED
@@ -1,27 +1,31 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path("lib", __dir__)
|
2
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
-
|
5
|
+
|
6
|
+
require "doorkeeper/jwt/version"
|
4
7
|
|
5
8
|
Gem::Specification.new do |spec|
|
6
|
-
spec.name
|
7
|
-
spec.version
|
8
|
-
spec.authors
|
9
|
-
spec.email
|
9
|
+
spec.name = "doorkeeper-jwt"
|
10
|
+
spec.version = Doorkeeper::JWT.gem_version
|
11
|
+
spec.authors = ["Chris Warren", "Nikita Bulai"]
|
12
|
+
spec.email = ["chris@expectless.com"]
|
10
13
|
|
11
|
-
spec.summary
|
12
|
-
spec.description
|
13
|
-
spec.homepage
|
14
|
-
spec.license
|
14
|
+
spec.summary = "JWT token generator for Doorkeeper"
|
15
|
+
spec.description = "JWT token generator extension for Doorkeeper"
|
16
|
+
spec.homepage = "https://github.com/chriswarren/doorkeeper-jwt"
|
17
|
+
spec.license = "MIT"
|
15
18
|
|
16
|
-
spec.
|
17
|
-
spec.
|
18
|
-
spec.executables
|
19
|
+
spec.bindir = "exe"
|
20
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
23
|
spec.require_paths = ["lib"]
|
20
24
|
|
21
|
-
spec.add_dependency "jwt", "
|
25
|
+
spec.add_dependency "jwt", ">= 2.1"
|
22
26
|
|
23
|
-
spec.add_development_dependency "bundler", "
|
27
|
+
spec.add_development_dependency "bundler", ">= 1.16", "< 3"
|
24
28
|
spec.add_development_dependency "pry", "~> 0"
|
25
|
-
spec.add_development_dependency "rake", "~>
|
26
|
-
spec.add_development_dependency "rspec", "~> 3.
|
29
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
30
|
+
spec.add_development_dependency "rspec", "~> 3.8"
|
27
31
|
end
|
@@ -4,7 +4,7 @@ module Doorkeeper
|
|
4
4
|
module JWT
|
5
5
|
class MissingConfiguration < StandardError
|
6
6
|
def initialize
|
7
|
-
super(
|
7
|
+
super("Configuration for doorkeeper-jwt missing.")
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
@@ -13,7 +13,7 @@ module Doorkeeper
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def self.configuration
|
16
|
-
@config || (
|
16
|
+
@config || raise(MissingConfiguration)
|
17
17
|
end
|
18
18
|
|
19
19
|
class Config
|
@@ -27,76 +27,73 @@ module Doorkeeper
|
|
27
27
|
@config
|
28
28
|
end
|
29
29
|
|
30
|
-
def use_application_secret(
|
31
|
-
@config.instance_variable_set(
|
32
|
-
'@use_application_secret',
|
33
|
-
use_application_secret
|
34
|
-
)
|
30
|
+
def use_application_secret(value)
|
31
|
+
@config.instance_variable_set("@use_application_secret", value)
|
35
32
|
end
|
36
33
|
|
37
|
-
def secret_key(
|
38
|
-
@config.instance_variable_set(
|
34
|
+
def secret_key(value)
|
35
|
+
@config.instance_variable_set("@secret_key", value)
|
39
36
|
end
|
40
37
|
|
41
|
-
def secret_key_path(
|
42
|
-
@config.instance_variable_set(
|
38
|
+
def secret_key_path(value)
|
39
|
+
@config.instance_variable_set("@secret_key_path", value)
|
43
40
|
end
|
44
41
|
|
45
|
-
def encryption_method(
|
46
|
-
@config.instance_variable_set(
|
47
|
-
'@encryption_method', encryption_method
|
48
|
-
)
|
42
|
+
def encryption_method(value)
|
43
|
+
@config.instance_variable_set("@encryption_method", value)
|
49
44
|
end
|
50
45
|
end
|
51
46
|
|
52
47
|
module Option
|
53
|
-
# Defines configuration
|
48
|
+
# Defines configuration options.
|
54
49
|
#
|
55
|
-
# When you call option, it defines two methods. One method will take
|
56
|
-
# in the +Config+ class and the other method will take place in
|
57
|
-
# +Builder+ class.
|
50
|
+
# When you call option, it defines two methods. One method will take
|
51
|
+
# place in the +Config+ class and the other method will take place in
|
52
|
+
# the +Builder+ class.
|
58
53
|
#
|
59
|
-
# The +name+ parameter will set both builder method and config
|
60
|
-
# If the +:as+ option is defined, the builder method will be
|
61
|
-
# option while the config attribute will be the +name+
|
54
|
+
# The +name+ parameter will set both builder method and config
|
55
|
+
# attribute. If the +:as+ option is defined, the builder method will be
|
56
|
+
# the specified option while the config attribute will be the +name+
|
57
|
+
# parameter.
|
62
58
|
#
|
63
|
-
# If you want to introduce another level of config DSL you can
|
64
|
-
#
|
65
|
-
#
|
66
|
-
#
|
59
|
+
# If you want to introduce another level of config DSL you can define
|
60
|
+
# +builder_class+ parameter. Builder should take a block as the
|
61
|
+
# initializer parameter and respond to function +build+ that returns the
|
62
|
+
# value of the config attribute.
|
67
63
|
#
|
68
64
|
# ==== Options
|
69
65
|
#
|
70
|
-
# * [
|
71
|
-
# * [+:default+] The default value in case no option was set
|
66
|
+
# * [+:as+] Set the builder method that goes inside +configure+ block.
|
67
|
+
# * [+:default+] The default value in case no option was set.
|
72
68
|
#
|
73
69
|
# ==== Examples
|
74
70
|
#
|
75
|
-
#
|
76
|
-
#
|
77
|
-
#
|
78
|
-
#
|
79
|
-
#
|
71
|
+
# option :name
|
72
|
+
# option :name, as: :set_name
|
73
|
+
# option :name, default: 'My Name'
|
74
|
+
# option :scopes, builder_class: ScopesBuilder
|
80
75
|
def option(name, options = {})
|
81
76
|
attribute = options[:as] || name
|
82
77
|
attribute_builder = options[:builder_class]
|
78
|
+
attribute_symbol = :"@#{attribute}"
|
83
79
|
|
84
80
|
Builder.instance_eval do
|
85
81
|
define_method name do |*args, &block|
|
86
82
|
# TODO: is builder_class option being used?
|
87
|
-
value =
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
83
|
+
value =
|
84
|
+
if attribute_builder
|
85
|
+
attribute_builder.new(&block).build
|
86
|
+
else
|
87
|
+
block || args.first
|
88
|
+
end
|
89
|
+
|
90
|
+
@config.instance_variable_set(attribute_symbol, value)
|
94
91
|
end
|
95
92
|
end
|
96
93
|
|
97
94
|
define_method attribute do |*|
|
98
|
-
if instance_variable_defined?(
|
99
|
-
instance_variable_get(
|
95
|
+
if instance_variable_defined?(attribute_symbol)
|
96
|
+
instance_variable_get(attribute_symbol)
|
100
97
|
else
|
101
98
|
options[:default]
|
102
99
|
end
|
@@ -112,8 +109,11 @@ module Doorkeeper
|
|
112
109
|
|
113
110
|
extend Option
|
114
111
|
|
115
|
-
option
|
116
|
-
|
112
|
+
option(
|
113
|
+
:token_payload,
|
114
|
+
default: proc { { token: SecureRandom.method(:hex) } }
|
115
|
+
)
|
116
|
+
|
117
117
|
option :token_headers, default: proc { {} }
|
118
118
|
option :use_application_secret, default: false
|
119
119
|
option :secret_key, default: nil
|
@@ -9,12 +9,12 @@ module Doorkeeper
|
|
9
9
|
module VERSION
|
10
10
|
# Semantic versioning
|
11
11
|
MAJOR = 0
|
12
|
-
MINOR =
|
13
|
-
TINY =
|
12
|
+
MINOR = 4
|
13
|
+
TINY = 1
|
14
14
|
PRE = nil
|
15
15
|
|
16
16
|
# Full version number
|
17
|
-
STRING = [MAJOR, MINOR, TINY, PRE].compact.join(
|
17
|
+
STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "doorkeeper
|
4
|
-
require "doorkeeper
|
5
|
-
require
|
3
|
+
require "doorkeeper/jwt/version"
|
4
|
+
require "doorkeeper/jwt/config"
|
5
|
+
require "jwt"
|
6
6
|
|
7
7
|
module Doorkeeper
|
8
8
|
module JWT
|
@@ -19,11 +19,11 @@ module Doorkeeper
|
|
19
19
|
private
|
20
20
|
|
21
21
|
def token_payload(opts = {})
|
22
|
-
Doorkeeper::JWT.configuration.token_payload.call
|
22
|
+
Doorkeeper::JWT.configuration.token_payload.call(opts)
|
23
23
|
end
|
24
24
|
|
25
25
|
def token_headers(opts = {})
|
26
|
-
Doorkeeper::JWT.configuration.token_headers.call
|
26
|
+
Doorkeeper::JWT.configuration.token_headers.call(opts)
|
27
27
|
end
|
28
28
|
|
29
29
|
def secret_key(opts)
|
@@ -33,6 +33,7 @@ module Doorkeeper
|
|
33
33
|
return secret_key_file unless secret_key_file.nil?
|
34
34
|
return rsa_key if rsa_encryption?
|
35
35
|
return ecdsa_key if ecdsa_encryption?
|
36
|
+
|
36
37
|
Doorkeeper::JWT.configuration.secret_key
|
37
38
|
end
|
38
39
|
|
@@ -44,6 +45,7 @@ module Doorkeeper
|
|
44
45
|
|
45
46
|
def encryption_method
|
46
47
|
return "none" unless Doorkeeper::JWT.configuration.encryption_method
|
48
|
+
|
47
49
|
Doorkeeper::JWT.configuration.encryption_method.to_s.upcase
|
48
50
|
end
|
49
51
|
|
@@ -53,17 +55,32 @@ module Doorkeeper
|
|
53
55
|
|
54
56
|
def application_secret(opts)
|
55
57
|
if opts[:application].nil?
|
56
|
-
raise
|
57
|
-
"
|
58
|
-
"params."
|
58
|
+
raise(
|
59
|
+
"JWT `use_application_secret` is enabled, but application is nil." \
|
60
|
+
" This can happen if `client_id` was absent in the request params."
|
61
|
+
)
|
59
62
|
end
|
60
63
|
|
61
|
-
if opts[:application]
|
62
|
-
|
63
|
-
|
64
|
+
secret = if opts[:application].respond_to?(:plaintext_secret)
|
65
|
+
unless opts[:application].secret_strategy.allows_restoring_secrets?
|
66
|
+
raise(
|
67
|
+
"JWT `use_application_secret` is enabled, but secret strategy " \
|
68
|
+
"doesn't allow plaintext secret restoring"
|
69
|
+
)
|
70
|
+
end
|
71
|
+
opts[:application].plaintext_secret
|
72
|
+
else
|
73
|
+
opts[:application][:secret]
|
74
|
+
end
|
75
|
+
|
76
|
+
if secret.nil?
|
77
|
+
raise(
|
78
|
+
"JWT `use_application_secret` is enabled, but the application" \
|
79
|
+
" secret is nil."
|
80
|
+
)
|
64
81
|
end
|
65
82
|
|
66
|
-
|
83
|
+
secret
|
67
84
|
end
|
68
85
|
|
69
86
|
def rsa_encryption?
|
metadata
CHANGED
@@ -1,55 +1,50 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: doorkeeper-jwt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Warren
|
8
|
+
- Nikita Bulai
|
8
9
|
autorequire:
|
9
10
|
bindir: exe
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2022-02-23 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: jwt
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
16
17
|
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 2.1.0
|
20
18
|
- - ">="
|
21
19
|
- !ruby/object:Gem::Version
|
22
|
-
version: 2.1
|
20
|
+
version: '2.1'
|
23
21
|
type: :runtime
|
24
22
|
prerelease: false
|
25
23
|
version_requirements: !ruby/object:Gem::Requirement
|
26
24
|
requirements:
|
27
|
-
- - "~>"
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: 2.1.0
|
30
25
|
- - ">="
|
31
26
|
- !ruby/object:Gem::Version
|
32
|
-
version: 2.1
|
27
|
+
version: '2.1'
|
33
28
|
- !ruby/object:Gem::Dependency
|
34
29
|
name: bundler
|
35
30
|
requirement: !ruby/object:Gem::Requirement
|
36
31
|
requirements:
|
37
|
-
- - "~>"
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
version: '1.8'
|
40
32
|
- - ">="
|
41
33
|
- !ruby/object:Gem::Version
|
42
|
-
version: '1.
|
34
|
+
version: '1.16'
|
35
|
+
- - "<"
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '3'
|
43
38
|
type: :development
|
44
39
|
prerelease: false
|
45
40
|
version_requirements: !ruby/object:Gem::Requirement
|
46
41
|
requirements:
|
47
|
-
- - "~>"
|
48
|
-
- !ruby/object:Gem::Version
|
49
|
-
version: '1.8'
|
50
42
|
- - ">="
|
51
43
|
- !ruby/object:Gem::Version
|
52
|
-
version: '1.
|
44
|
+
version: '1.16'
|
45
|
+
- - "<"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3'
|
53
48
|
- !ruby/object:Gem::Dependency
|
54
49
|
name: pry
|
55
50
|
requirement: !ruby/object:Gem::Requirement
|
@@ -70,40 +65,28 @@ dependencies:
|
|
70
65
|
requirements:
|
71
66
|
- - "~>"
|
72
67
|
- !ruby/object:Gem::Version
|
73
|
-
version: '
|
74
|
-
- - ">="
|
75
|
-
- !ruby/object:Gem::Version
|
76
|
-
version: '10.0'
|
68
|
+
version: '13.0'
|
77
69
|
type: :development
|
78
70
|
prerelease: false
|
79
71
|
version_requirements: !ruby/object:Gem::Requirement
|
80
72
|
requirements:
|
81
73
|
- - "~>"
|
82
74
|
- !ruby/object:Gem::Version
|
83
|
-
version: '
|
84
|
-
- - ">="
|
85
|
-
- !ruby/object:Gem::Version
|
86
|
-
version: '10.0'
|
75
|
+
version: '13.0'
|
87
76
|
- !ruby/object:Gem::Dependency
|
88
77
|
name: rspec
|
89
78
|
requirement: !ruby/object:Gem::Requirement
|
90
79
|
requirements:
|
91
80
|
- - "~>"
|
92
81
|
- !ruby/object:Gem::Version
|
93
|
-
version: 3.
|
94
|
-
- - ">="
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '3.2'
|
82
|
+
version: '3.8'
|
97
83
|
type: :development
|
98
84
|
prerelease: false
|
99
85
|
version_requirements: !ruby/object:Gem::Requirement
|
100
86
|
requirements:
|
101
87
|
- - "~>"
|
102
88
|
- !ruby/object:Gem::Version
|
103
|
-
version: 3.
|
104
|
-
- - ">="
|
105
|
-
- !ruby/object:Gem::Version
|
106
|
-
version: '3.2'
|
89
|
+
version: '3.8'
|
107
90
|
description: JWT token generator extension for Doorkeeper
|
108
91
|
email:
|
109
92
|
- chris@expectless.com
|
@@ -111,10 +94,12 @@ executables: []
|
|
111
94
|
extensions: []
|
112
95
|
extra_rdoc_files: []
|
113
96
|
files:
|
97
|
+
- ".github/dependabot.yml"
|
98
|
+
- ".github/workflows/ci.yml"
|
114
99
|
- ".gitignore"
|
100
|
+
- ".hound.yml"
|
115
101
|
- ".rspec"
|
116
102
|
- ".rubocop.yml"
|
117
|
-
- ".travis.yml"
|
118
103
|
- CHANGELOG.md
|
119
104
|
- Gemfile
|
120
105
|
- LICENSE.txt
|
@@ -123,10 +108,9 @@ files:
|
|
123
108
|
- bin/console
|
124
109
|
- bin/setup
|
125
110
|
- doorkeeper-jwt.gemspec
|
126
|
-
- lib/doorkeeper
|
127
|
-
- lib/doorkeeper
|
128
|
-
- lib/doorkeeper
|
129
|
-
- lib/doorkeeper-jwt/version.rb
|
111
|
+
- lib/doorkeeper/jwt.rb
|
112
|
+
- lib/doorkeeper/jwt/config.rb
|
113
|
+
- lib/doorkeeper/jwt/version.rb
|
130
114
|
homepage: https://github.com/chriswarren/doorkeeper-jwt
|
131
115
|
licenses:
|
132
116
|
- MIT
|
@@ -146,8 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
146
130
|
- !ruby/object:Gem::Version
|
147
131
|
version: '0'
|
148
132
|
requirements: []
|
149
|
-
|
150
|
-
rubygems_version: 2.6.11
|
133
|
+
rubygems_version: 3.0.8
|
151
134
|
signing_key:
|
152
135
|
specification_version: 4
|
153
136
|
summary: JWT token generator for Doorkeeper
|
data/.travis.yml
DELETED