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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 32f8802b270dd6aff8c6ded3545b79fc84be4fa2dc856401e39f60a2818ef986
4
- data.tar.gz: adfeb942ae99d8631d44cdeb722c6e40967b2319cc1398191bcb22ca50f2e047
3
+ metadata.gz: '04826fc219f000cfbb34243981e137fdc91f54d4aaf9d2e4ee16c8db5bc80763'
4
+ data.tar.gz: 2cd2fe00356eae0b93a461c0aa58b52c489ae457a93f69cd1dcd73757b51746e
5
5
  SHA512:
6
- metadata.gz: 4a24d1a2a83d19d1bbe96b57da628bd3cd42842e1dd92a782b3bbe16b98cd6fa0594a79f83d61d6b22db6f46716c986b3e3a7eb3b948bce29fd093234baad84b
7
- data.tar.gz: 55d64e0e301287f05b07548b7110c04c83fbef478bb43d09b4ce03a72d235a45bfaa44349ab77f58922cdb7fe4bfa8918adc25fa818c203c5ec778cf3ac1c846
6
+ metadata.gz: efa77d9a020f5a5665365acd3dccd9605a30c0bf7fd4d9b60027b0ed0827aa2a11f93dc45a7857609fe690be98fd8f8b34cabf025648dfcfd1a1cc5dd91f72ac
7
+ data.tar.gz: bb8d14619a2a724047d46c25f6f3c0127bd52f94834128037059883f98842159fdac71edd88bdcc1d9f2fadf96cb7c9c896f24171d5a1eed9cd1e16474979568
@@ -0,0 +1,7 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: bundler
4
+ directory: "/"
5
+ schedule:
6
+ interval: daily
7
+ open-pull-requests-limit: 10
@@ -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
@@ -1,2 +1,3 @@
1
1
  rubocop:
2
2
  config_file: .rubocop.yml
3
+ version: 0.72.0
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
- Enabled: false
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
- Metrics/MethodLength:
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-06-11
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 'https://rubygems.org'
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 'coveralls', require: false
9
- gem 'rubocop', '~> 0.59.2', require: false
10
- gem 'rubocop-rspec', '~> 1.30', require: false
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
- token_headers do |opts|
66
- { kid: opts[:application][:uid] }
67
- end
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 encryption secret. This would be shared with any other applications
75
- # that should be able to read the payload of the token. Defaults to "secret".
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* encoding specify the path to the RSA key to use for
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 encryption type (https://github.com/progrium/ruby-jwt). Defaults to
87
+ # Specify cryptographic signing algorithm type (https://github.com/progrium/ruby-jwt). Defaults to
84
88
  # `nil`.
85
- encryption_method :hs512
89
+ signing_method :hs512
86
90
  end
87
91
  ```
88
92
 
data/Rakefile CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bundler/gem_tasks'
4
- require 'rspec/core/rake_task'
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
5
 
6
6
  RSpec::Core::RakeTask.new
7
7
 
data/bin/console CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- require 'bundler/setup'
5
- require 'doorkeeper-jwt'
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 'irb'
15
+ require "irb"
16
16
 
17
17
  IRB.start
@@ -1,31 +1,31 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- lib = File.expand_path('lib', __dir__)
3
+ lib = File.expand_path("lib", __dir__)
4
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
 
6
- require 'doorkeeper/jwt/version'
6
+ require "doorkeeper/jwt/version"
7
7
 
8
8
  Gem::Specification.new do |spec|
9
- spec.name = 'doorkeeper-jwt'
9
+ spec.name = "doorkeeper-jwt"
10
10
  spec.version = Doorkeeper::JWT.gem_version
11
- spec.authors = ['Chris Warren']
12
- spec.email = ['chris@expectless.com']
11
+ spec.authors = ["Chris Warren", "Nikita Bulai"]
12
+ spec.email = ["chris@expectless.com"]
13
13
 
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'
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 = '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']
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 'jwt', '~> 2.1'
25
+ spec.add_dependency "jwt", ">= 2.1"
26
26
 
27
- spec.add_development_dependency 'bundler', '>= 1.16', '< 3'
28
- spec.add_development_dependency 'pry', '~> 0'
29
- spec.add_development_dependency 'rake', '~> 12.3'
30
- spec.add_development_dependency 'rspec', '~> 3.8'
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('Configuration for doorkeeper-jwt missing.')
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('@use_application_secret', value)
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('@secret_key', value)
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('@secret_key_path', value)
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('@encryption_method', value)
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.method(:hex) } }
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 :encryption_method, default: nil
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 encryption_method
136
- @encryption_method ||= nil
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 = 0
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
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'doorkeeper/jwt/version'
4
- require 'doorkeeper/jwt/config'
5
- require 'jwt'
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
- encryption_method,
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 rsa_encryption?
35
- return ecdsa_key if ecdsa_encryption?
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 rsa_encryption?
43
- return ecdsa_key_file if ecdsa_encryption?
42
+ return rsa_key_file if rsa_signing?
43
+ return ecdsa_key_file if ecdsa_signing?
44
44
  end
45
45
 
46
- def encryption_method
47
- return 'none' unless Doorkeeper::JWT.configuration.encryption_method
46
+ def signing_method
47
+ return "none" unless Doorkeeper::JWT.configuration.signing_method
48
48
 
49
- Doorkeeper::JWT.configuration.encryption_method.to_s.upcase
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
- 'JWT `use_application_secret` is enabled, but application is nil.' \
60
- ' This can happen if `client_id` was absent in the request params.'
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
- 'JWT `use_application_secret` is enabled, but the application' \
79
- ' secret is nil.'
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 rsa_encryption?
87
- /RS\d{3}/ =~ encryption_method
86
+ def rsa_signing?
87
+ /RS\d{3}/ =~ signing_method
88
88
  end
89
89
 
90
- def ecdsa_encryption?
91
- /ES\d{3}/ =~ encryption_method
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.0
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: 2019-10-02 00:00:00.000000000 Z
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: '12.3'
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: '12.3'
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.0.2
133
+ rubygems_version: 3.1.6
132
134
  signing_key:
133
135
  specification_version: 4
134
136
  summary: JWT token generator for Doorkeeper
data/.travis.yml DELETED
@@ -1,6 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.2
4
- - 2.3
5
- - 2.4
6
- - 2.5