doorkeeper-jwt 0.4.0 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +7 -0
- data/.github/workflows/ci.yml +38 -0
- data/.hound.yml +1 -0
- data/.rubocop.yml +38 -2
- data/CHANGELOG.md +16 -1
- data/Gemfile +4 -4
- data/README.md +12 -8
- data/Rakefile +2 -2
- data/bin/console +3 -3
- data/doorkeeper-jwt.gemspec +19 -19
- data/lib/doorkeeper/jwt/config.rb +15 -9
- data/lib/doorkeeper/jwt/version.rb +2 -2
- data/lib/doorkeeper/jwt.rb +19 -19
- metadata +10 -8
- data/.travis.yml +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '04826fc219f000cfbb34243981e137fdc91f54d4aaf9d2e4ee16c8db5bc80763'
|
4
|
+
data.tar.gz: 2cd2fe00356eae0b93a461c0aa58b52c489ae457a93f69cd1dcd73757b51746e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: efa77d9a020f5a5665365acd3dccd9605a30c0bf7fd4d9b60027b0ed0827aa2a11f93dc45a7857609fe690be98fd8f8b34cabf025648dfcfd1a1cc5dd91f72ac
|
7
|
+
data.tar.gz: bb8d14619a2a724047d46c25f6f3c0127bd52f94834128037059883f98842159fdac71edd88bdcc1d9f2fadf96cb7c9c896f24171d5a1eed9cd1e16474979568
|
@@ -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/.hound.yml
CHANGED
data/.rubocop.yml
CHANGED
@@ -8,12 +8,48 @@ AllCops:
|
|
8
8
|
ExtraDetails: true
|
9
9
|
TargetRubyVersion: 2.5
|
10
10
|
|
11
|
+
Metrics/LineLength:
|
12
|
+
Exclude:
|
13
|
+
- spec/**/*
|
14
|
+
Max: 100
|
15
|
+
|
11
16
|
Metrics/BlockLength:
|
12
|
-
|
17
|
+
Exclude:
|
18
|
+
- spec/**/*
|
19
|
+
- doorkeeper-jwt.gemspec
|
20
|
+
|
21
|
+
Style/StringLiterals:
|
22
|
+
EnforcedStyle: double_quotes
|
23
|
+
Style/StringLiteralsInInterpolation:
|
24
|
+
EnforcedStyle: double_quotes
|
13
25
|
|
14
|
-
|
26
|
+
Style/FrozenStringLiteralComment:
|
27
|
+
Enabled: true
|
28
|
+
|
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:
|
40
|
+
Exclude:
|
41
|
+
- spec/**/*
|
42
|
+
Style/NumericPredicate:
|
43
|
+
Enabled: false
|
44
|
+
Style/DoubleNegation:
|
15
45
|
Enabled: false
|
16
46
|
|
47
|
+
Layout/MultilineMethodCallIndentation:
|
48
|
+
EnforcedStyle: indented
|
49
|
+
Layout/TrailingBlankLines:
|
50
|
+
Enabled: true
|
51
|
+
Layout/DotPosition:
|
52
|
+
EnforcedStyle: leading
|
17
53
|
|
18
54
|
Naming/FileName:
|
19
55
|
Exclude:
|
data/CHANGELOG.md
CHANGED
@@ -6,9 +6,24 @@ project adheres to [Semantic Versioning](http://semver.org/).
|
|
6
6
|
|
7
7
|
## master
|
8
8
|
|
9
|
+
Add here
|
10
|
+
|
11
|
+
## [0.4.2] - 2024-08-12
|
12
|
+
|
13
|
+
- Rename encryption_method to signing_method [#53](https://github.com/doorkeeper-gem/doorkeeper-jwt/pull/53)
|
14
|
+
- Fix default token generation [#56](https://github.com/doorkeeper-gem/doorkeeper-jwt/pull/56)
|
15
|
+
|
16
|
+
### Fixed
|
17
|
+
|
18
|
+
- Fixed default token generation to return a random hex value [#56](https://github.com/doorkeeper-gem/doorkeeper-jwt/pull/56)
|
19
|
+
|
20
|
+
## [0.4.1] - 2022-02-23
|
21
|
+
|
22
|
+
- JWT gem requirement relaxed to use any version >= 2.1
|
23
|
+
|
9
24
|
### Changed
|
10
25
|
|
11
|
-
## [0.4.0] - 2019-
|
26
|
+
## [0.4.0] - 2019-10-02
|
12
27
|
|
13
28
|
- Restructured library files to follow naming conventions. (https://guides.rubygems.org/name-your-gem/).
|
14
29
|
- Add support of new doorkeeper with encryption [#30](https://github.com/doorkeeper-gem/doorkeeper-jwt/pull/30)
|
data/Gemfile
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
source
|
3
|
+
source "https://rubygems.org"
|
4
4
|
|
5
5
|
# Specify your gem's dependencies in doorkeeper-jwt.gemspec
|
6
6
|
gemspec
|
7
7
|
|
8
|
-
gem
|
9
|
-
gem
|
10
|
-
gem
|
8
|
+
gem "coveralls", require: false
|
9
|
+
gem "rubocop", "~> 1.8", require: false
|
10
|
+
gem "rubocop-rspec", "~> 3.0", require: false
|
data/README.md
CHANGED
@@ -49,9 +49,11 @@ Doorkeeper::JWT.configure do
|
|
49
49
|
{
|
50
50
|
iss: 'My App',
|
51
51
|
iat: Time.current.utc.to_i,
|
52
|
+
aud: opts[:application][:uid],
|
52
53
|
|
53
54
|
# @see JWT reserved claims - https://tools.ietf.org/html/draft-jones-json-web-token-07#page-7
|
54
55
|
jti: SecureRandom.uuid,
|
56
|
+
sub: user.id,
|
55
57
|
|
56
58
|
user: {
|
57
59
|
id: user.id,
|
@@ -62,27 +64,29 @@ Doorkeeper::JWT.configure do
|
|
62
64
|
|
63
65
|
# Optionally set additional headers for the JWT. See
|
64
66
|
# https://tools.ietf.org/html/rfc7515#section-4.1
|
65
|
-
|
66
|
-
|
67
|
-
|
67
|
+
# JWK can be used to automatically verify RS* tokens client-side if token's kid matches a public kid in /oauth/discovery/keys
|
68
|
+
# token_headers do |_opts|
|
69
|
+
# key = OpenSSL::PKey::RSA.new(File.read(File.join('path', 'to', 'file.pem')))
|
70
|
+
# { kid: JWT::JWK.new(key)[:kid] }
|
71
|
+
# end
|
68
72
|
|
69
73
|
# Use the application secret specified in the access grant token. Defaults to
|
70
74
|
# `false`. If you specify `use_application_secret true`, both `secret_key` and
|
71
75
|
# `secret_key_path` will be ignored.
|
72
76
|
use_application_secret false
|
73
77
|
|
74
|
-
# Set the
|
75
|
-
# that should be able to
|
78
|
+
# Set the signing secret. This would be shared with any other applications
|
79
|
+
# that should be able to verify the authenticity of the token. Defaults to "secret".
|
76
80
|
secret_key ENV['JWT_SECRET']
|
77
81
|
|
78
|
-
# If you want to use RS*
|
82
|
+
# If you want to use RS* algorithms specify the path to the RSA key to use for
|
79
83
|
# signing. If you specify a `secret_key_path` it will be used instead of
|
80
84
|
# `secret_key`.
|
81
85
|
secret_key_path File.join('path', 'to', 'file.pem')
|
82
86
|
|
83
|
-
# Specify
|
87
|
+
# Specify cryptographic signing algorithm type (https://github.com/progrium/ruby-jwt). Defaults to
|
84
88
|
# `nil`.
|
85
|
-
|
89
|
+
signing_method :hs512
|
86
90
|
end
|
87
91
|
```
|
88
92
|
|
data/Rakefile
CHANGED
data/bin/console
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
require
|
5
|
-
require
|
4
|
+
require "bundler/setup"
|
5
|
+
require "doorkeeper-jwt"
|
6
6
|
|
7
7
|
# You can add fixtures and/or initialization code here to make experimenting
|
8
8
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -12,6 +12,6 @@ require 'doorkeeper-jwt'
|
|
12
12
|
#
|
13
13
|
# Pry.start
|
14
14
|
|
15
|
-
require
|
15
|
+
require "irb"
|
16
16
|
|
17
17
|
IRB.start
|
data/doorkeeper-jwt.gemspec
CHANGED
@@ -1,31 +1,31 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
lib = File.expand_path(
|
3
|
+
lib = File.expand_path("lib", __dir__)
|
4
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
5
|
|
6
|
-
require
|
6
|
+
require "doorkeeper/jwt/version"
|
7
7
|
|
8
8
|
Gem::Specification.new do |spec|
|
9
|
-
spec.name
|
9
|
+
spec.name = "doorkeeper-jwt"
|
10
10
|
spec.version = Doorkeeper::JWT.gem_version
|
11
|
-
spec.authors = [
|
12
|
-
spec.email
|
11
|
+
spec.authors = ["Chris Warren", "Nikita Bulai"]
|
12
|
+
spec.email = ["chris@expectless.com"]
|
13
13
|
|
14
|
-
spec.summary
|
15
|
-
spec.description =
|
16
|
-
spec.homepage
|
17
|
-
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"
|
18
18
|
|
19
|
-
spec.bindir
|
20
|
-
spec.files
|
21
|
-
spec.executables
|
22
|
-
spec.test_files
|
23
|
-
spec.require_paths = [
|
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)/})
|
23
|
+
spec.require_paths = ["lib"]
|
24
24
|
|
25
|
-
spec.add_dependency
|
25
|
+
spec.add_dependency "jwt", ">= 2.1"
|
26
26
|
|
27
|
-
spec.add_development_dependency
|
28
|
-
spec.add_development_dependency
|
29
|
-
spec.add_development_dependency
|
30
|
-
spec.add_development_dependency
|
27
|
+
spec.add_development_dependency "bundler", ">= 1.16", "< 3"
|
28
|
+
spec.add_development_dependency "pry", "~> 0"
|
29
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
30
|
+
spec.add_development_dependency "rspec", "~> 3.8"
|
31
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
|
|
@@ -28,19 +28,25 @@ module Doorkeeper
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def use_application_secret(value)
|
31
|
-
@config.instance_variable_set(
|
31
|
+
@config.instance_variable_set("@use_application_secret", value)
|
32
32
|
end
|
33
33
|
|
34
34
|
def secret_key(value)
|
35
|
-
@config.instance_variable_set(
|
35
|
+
@config.instance_variable_set("@secret_key", value)
|
36
36
|
end
|
37
37
|
|
38
38
|
def secret_key_path(value)
|
39
|
-
@config.instance_variable_set(
|
39
|
+
@config.instance_variable_set("@secret_key_path", value)
|
40
40
|
end
|
41
41
|
|
42
|
+
# For backward compatibility. This library does not support encryption.
|
42
43
|
def encryption_method(value)
|
43
|
-
@config.instance_variable_set(
|
44
|
+
@config.instance_variable_set("@signing_method", value)
|
45
|
+
Kernel.warn("[DOORKEEPER-JWT]: Please use signing_method instead, this option is deprecated and will be removed soon")
|
46
|
+
end
|
47
|
+
|
48
|
+
def signing_method(value)
|
49
|
+
@config.instance_variable_set("@signing_method", value)
|
44
50
|
end
|
45
51
|
end
|
46
52
|
|
@@ -111,14 +117,14 @@ module Doorkeeper
|
|
111
117
|
|
112
118
|
option(
|
113
119
|
:token_payload,
|
114
|
-
default: proc { { token: SecureRandom.
|
120
|
+
default: proc { { token: SecureRandom.hex } },
|
115
121
|
)
|
116
122
|
|
117
123
|
option :token_headers, default: proc { {} }
|
118
124
|
option :use_application_secret, default: false
|
119
125
|
option :secret_key, default: nil
|
120
126
|
option :secret_key_path, default: nil
|
121
|
-
option :
|
127
|
+
option :signing_method, default: nil
|
122
128
|
|
123
129
|
def use_application_secret
|
124
130
|
@use_application_secret ||= false
|
@@ -132,8 +138,8 @@ module Doorkeeper
|
|
132
138
|
@secret_key_path ||= nil
|
133
139
|
end
|
134
140
|
|
135
|
-
def
|
136
|
-
@
|
141
|
+
def signing_method
|
142
|
+
@signing_method ||= nil
|
137
143
|
end
|
138
144
|
end
|
139
145
|
end
|
@@ -10,11 +10,11 @@ module Doorkeeper
|
|
10
10
|
# Semantic versioning
|
11
11
|
MAJOR = 0
|
12
12
|
MINOR = 4
|
13
|
-
TINY =
|
13
|
+
TINY = 2
|
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
|
data/lib/doorkeeper/jwt.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
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
|
@@ -11,7 +11,7 @@ module Doorkeeper
|
|
11
11
|
::JWT.encode(
|
12
12
|
token_payload(opts),
|
13
13
|
secret_key(opts),
|
14
|
-
|
14
|
+
signing_method,
|
15
15
|
token_headers(opts)
|
16
16
|
)
|
17
17
|
end
|
@@ -31,22 +31,22 @@ module Doorkeeper
|
|
31
31
|
|
32
32
|
return application_secret(opts) if use_application_secret?
|
33
33
|
return secret_key_file unless secret_key_file.nil?
|
34
|
-
return rsa_key if
|
35
|
-
return ecdsa_key if
|
34
|
+
return rsa_key if rsa_signing?
|
35
|
+
return ecdsa_key if ecdsa_signing?
|
36
36
|
|
37
37
|
Doorkeeper::JWT.configuration.secret_key
|
38
38
|
end
|
39
39
|
|
40
40
|
def secret_key_file
|
41
41
|
return nil if Doorkeeper::JWT.configuration.secret_key_path.nil?
|
42
|
-
return rsa_key_file if
|
43
|
-
return ecdsa_key_file if
|
42
|
+
return rsa_key_file if rsa_signing?
|
43
|
+
return ecdsa_key_file if ecdsa_signing?
|
44
44
|
end
|
45
45
|
|
46
|
-
def
|
47
|
-
return
|
46
|
+
def signing_method
|
47
|
+
return "none" unless Doorkeeper::JWT.configuration.signing_method
|
48
48
|
|
49
|
-
Doorkeeper::JWT.configuration.
|
49
|
+
Doorkeeper::JWT.configuration.signing_method.to_s.upcase
|
50
50
|
end
|
51
51
|
|
52
52
|
def use_application_secret?
|
@@ -56,8 +56,8 @@ module Doorkeeper
|
|
56
56
|
def application_secret(opts)
|
57
57
|
if opts[:application].nil?
|
58
58
|
raise(
|
59
|
-
|
60
|
-
|
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
61
|
)
|
62
62
|
end
|
63
63
|
|
@@ -75,20 +75,20 @@ module Doorkeeper
|
|
75
75
|
|
76
76
|
if secret.nil?
|
77
77
|
raise(
|
78
|
-
|
79
|
-
|
78
|
+
"JWT `use_application_secret` is enabled, but the application" \
|
79
|
+
" secret is nil."
|
80
80
|
)
|
81
81
|
end
|
82
82
|
|
83
83
|
secret
|
84
84
|
end
|
85
85
|
|
86
|
-
def
|
87
|
-
/RS\d{3}/ =~
|
86
|
+
def rsa_signing?
|
87
|
+
/RS\d{3}/ =~ signing_method
|
88
88
|
end
|
89
89
|
|
90
|
-
def
|
91
|
-
/ES\d{3}/ =~
|
90
|
+
def ecdsa_signing?
|
91
|
+
/ES\d{3}/ =~ signing_method
|
92
92
|
end
|
93
93
|
|
94
94
|
def rsa_key
|
metadata
CHANGED
@@ -1,27 +1,28 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: doorkeeper-jwt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
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: 2024-08-12 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
|
+
- - ">="
|
18
19
|
- !ruby/object:Gem::Version
|
19
20
|
version: '2.1'
|
20
21
|
type: :runtime
|
21
22
|
prerelease: false
|
22
23
|
version_requirements: !ruby/object:Gem::Requirement
|
23
24
|
requirements:
|
24
|
-
- - "
|
25
|
+
- - ">="
|
25
26
|
- !ruby/object:Gem::Version
|
26
27
|
version: '2.1'
|
27
28
|
- !ruby/object:Gem::Dependency
|
@@ -64,14 +65,14 @@ dependencies:
|
|
64
65
|
requirements:
|
65
66
|
- - "~>"
|
66
67
|
- !ruby/object:Gem::Version
|
67
|
-
version: '
|
68
|
+
version: '13.0'
|
68
69
|
type: :development
|
69
70
|
prerelease: false
|
70
71
|
version_requirements: !ruby/object:Gem::Requirement
|
71
72
|
requirements:
|
72
73
|
- - "~>"
|
73
74
|
- !ruby/object:Gem::Version
|
74
|
-
version: '
|
75
|
+
version: '13.0'
|
75
76
|
- !ruby/object:Gem::Dependency
|
76
77
|
name: rspec
|
77
78
|
requirement: !ruby/object:Gem::Requirement
|
@@ -93,11 +94,12 @@ executables: []
|
|
93
94
|
extensions: []
|
94
95
|
extra_rdoc_files: []
|
95
96
|
files:
|
97
|
+
- ".github/dependabot.yml"
|
98
|
+
- ".github/workflows/ci.yml"
|
96
99
|
- ".gitignore"
|
97
100
|
- ".hound.yml"
|
98
101
|
- ".rspec"
|
99
102
|
- ".rubocop.yml"
|
100
|
-
- ".travis.yml"
|
101
103
|
- CHANGELOG.md
|
102
104
|
- Gemfile
|
103
105
|
- LICENSE.txt
|
@@ -128,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
130
|
- !ruby/object:Gem::Version
|
129
131
|
version: '0'
|
130
132
|
requirements: []
|
131
|
-
rubygems_version: 3.
|
133
|
+
rubygems_version: 3.1.6
|
132
134
|
signing_key:
|
133
135
|
specification_version: 4
|
134
136
|
summary: JWT token generator for Doorkeeper
|