jwt 2.2.3 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +1 -1
- data/.rubocop_todo.yml +0 -6
- data/AUTHORS +59 -48
- data/CHANGELOG.md +37 -2
- data/README.md +34 -18
- data/lib/jwt/algos/eddsa.rb +11 -4
- data/lib/jwt/decode.rb +2 -0
- data/lib/jwt/default_options.rb +2 -1
- data/lib/jwt/error.rb +1 -0
- data/lib/jwt/jwk/ec.rb +2 -2
- data/lib/jwt/jwk.rb +2 -2
- data/lib/jwt/verify.rb +8 -1
- data/lib/jwt/version.rb +2 -2
- data/ruby-jwt.gemspec +4 -0
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a43128b4e2f4d47a90b9834ad66b65411794d599660e459f3296ad5eea043a74
|
4
|
+
data.tar.gz: 158319e4108c4001f499fe13195d6659e90e741a1e563fbc6f531bf820fb50e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2b714380b47796ead0390f84650d11b0c7a963256cb7475e122e71c7eebfd94af97bf029f091f7916c2c37819eef7795899112e0bdf685a5634445bdf307dce
|
7
|
+
data.tar.gz: a80b9e615d14c8fb673973b4bd9b76aaf2c9685298c0d2c2fd39a50902ddc62900ba2680b2c207593dfc9ea7993c72649c0e535d2a04c50d34c95c37c220b242
|
data/.github/workflows/test.yml
CHANGED
data/.rubocop_todo.yml
CHANGED
@@ -134,12 +134,6 @@ Style/ModuleFunction:
|
|
134
134
|
- 'lib/jwt/algos.rb'
|
135
135
|
- 'lib/jwt/signature.rb'
|
136
136
|
|
137
|
-
# Offense count: 1
|
138
|
-
# Cop supports --auto-correct.
|
139
|
-
Style/MultilineIfModifier:
|
140
|
-
Exclude:
|
141
|
-
- 'spec/integration/readme_examples_spec.rb'
|
142
|
-
|
143
137
|
# Offense count: 1
|
144
138
|
# Cop supports --auto-correct.
|
145
139
|
Style/MutableConstant:
|
data/AUTHORS
CHANGED
@@ -8,94 +8,105 @@ Emilio Cristalli
|
|
8
8
|
Egon Zemmer
|
9
9
|
Zane Shannon
|
10
10
|
Nikita Shatov
|
11
|
-
Oliver
|
12
11
|
Paul Battley
|
12
|
+
Oliver
|
13
13
|
blackanger
|
14
14
|
Adam Michael
|
15
|
+
James Stonehill
|
15
16
|
Ville Lautanala
|
16
17
|
Tyler Pickett
|
17
|
-
James Stonehill
|
18
18
|
Peter M. Goldstein
|
19
19
|
Martin Emde
|
20
|
-
Richard Larocque
|
21
20
|
Korstiaan de Ridder
|
22
|
-
|
23
|
-
|
24
|
-
Steve Sloan
|
25
|
-
Yason Khaburzaniya
|
21
|
+
Richard Larocque
|
22
|
+
Andrew Davis
|
26
23
|
Bill Mill
|
24
|
+
Yason Khaburzaniya
|
25
|
+
Steve Sloan
|
26
|
+
Nick Hammond
|
27
|
+
Antonis Berkakis
|
28
|
+
Klaas Jan Wierenga
|
29
|
+
yann ARMAND
|
30
|
+
Brian Flethcer
|
31
|
+
Erik Michaels-Ober
|
32
|
+
Jurriaan Pruis
|
33
|
+
Kevin Olbrich
|
34
|
+
Larry Lv
|
35
|
+
Rodrigo López Dato
|
36
|
+
Simon Fish
|
37
|
+
Steven Davidovitz
|
38
|
+
Tom Wey
|
27
39
|
jb08
|
28
40
|
lukas
|
29
|
-
Rodrigo López Dato
|
30
41
|
ojab
|
31
42
|
sawyerzhang
|
32
|
-
Kevin Olbrich
|
33
43
|
smudge
|
34
44
|
wohlgejm
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
45
|
+
Julio Lopez
|
46
|
+
Katelyn Kasperowicz
|
47
|
+
fusagiko/takayamaki
|
48
|
+
Dorian Marié
|
49
|
+
rono23
|
50
|
+
Leonardo Saraiva
|
51
|
+
Lowell Kirsh
|
52
|
+
Lucas Mazza
|
53
|
+
Makoto Chiba
|
54
|
+
Manuel Bustillo
|
55
|
+
Marco Adkins
|
56
|
+
Dave Grijalva
|
57
|
+
Micah Gates
|
58
|
+
Michał Begejowicz
|
59
|
+
Mike Eirih
|
60
|
+
Mike Pastore
|
42
61
|
Mingan
|
43
62
|
Mitch Birti
|
63
|
+
Dan Leyden
|
44
64
|
Nicolas Leger
|
65
|
+
Brandon Keepers
|
66
|
+
Bouke van der Bijl
|
67
|
+
B
|
68
|
+
Pierre Michard
|
69
|
+
RahulBajaj
|
70
|
+
Austin Kabiru
|
71
|
+
Ritikesh
|
45
72
|
Rob Wygand
|
73
|
+
Adam Greene
|
46
74
|
Ryan Brushett
|
47
75
|
Ryan McIlmoyl
|
48
76
|
Ryan Metzler
|
77
|
+
Severin Schoepke
|
78
|
+
Shaun Guth
|
79
|
+
mai fujii
|
80
|
+
Artsiom Kuts
|
49
81
|
Steve Teti
|
82
|
+
nycvotes-dev
|
50
83
|
T.J. Schuck
|
51
84
|
Taiki Sugawara
|
52
85
|
Takehiro Adachi
|
86
|
+
Arnaud Mesureur
|
53
87
|
Tobias Haar
|
54
88
|
Toby Pinder
|
89
|
+
revodoge
|
55
90
|
Tomé Duarte
|
56
91
|
Travis Hunter
|
92
|
+
Ariel Salomon
|
93
|
+
Aman Gupta
|
94
|
+
Alexandr Kostrikov
|
57
95
|
Yuji Yaginuma
|
96
|
+
Alexander Boyd
|
58
97
|
Zuzanna Stolińska
|
59
98
|
aarongray
|
60
|
-
danielgrippi
|
61
|
-
nycvotes-dev
|
62
|
-
revodoge
|
63
|
-
rono23
|
64
|
-
RahulBajaj
|
65
|
-
Adam Greene
|
66
|
-
Alexander Boyd
|
67
|
-
Alexandr Kostrikov
|
68
|
-
Aman Gupta
|
69
|
-
Ariel Salomon
|
70
|
-
Arnaud Mesureur
|
71
|
-
Artsiom Kuts
|
72
|
-
Austin Kabiru
|
73
|
-
B
|
74
|
-
Brandon Keepers
|
75
|
-
Dan Leyden
|
76
|
-
Dave Grijalva
|
77
|
-
Dorian Marié
|
78
|
-
Ernie Miller
|
79
|
-
Evgeni Golov
|
80
|
-
Ewoud Kohl van Wijngaarden
|
81
99
|
HoneyryderChuck
|
82
100
|
Igor Victor
|
83
101
|
Ilyaaaaaaaaaaaaa Zhitomirskiy
|
102
|
+
Ewoud Kohl van Wijngaarden
|
103
|
+
Evgeni Golov
|
84
104
|
Jens Hausherr
|
85
105
|
Jeremiah Wuenschel
|
106
|
+
Ernie Miller
|
86
107
|
John Downey
|
87
108
|
Jordan Brough
|
88
109
|
Josh Bodah
|
89
110
|
JotaSe
|
90
111
|
Juanito Fatas
|
91
|
-
|
92
|
-
Katelyn Kasperowicz
|
93
|
-
Lowell Kirsh
|
94
|
-
Lucas Mazza
|
95
|
-
Makoto Chiba
|
96
|
-
Manuel Bustillo
|
97
|
-
Marco Adkins
|
98
|
-
Micah Gates
|
99
|
-
Michał Begejowicz
|
100
|
-
Mike Eirih
|
101
|
-
Mike Pastore
|
112
|
+
danielgrippi
|
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,42 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
-
## [
|
3
|
+
## [v2.3.0](https://github.com/jwt/ruby-jwt/tree/v2.3.0) (2021-10-03)
|
4
4
|
|
5
|
-
[Full Changelog](https://github.com/jwt/ruby-jwt/compare/v2.2.
|
5
|
+
[Full Changelog](https://github.com/jwt/ruby-jwt/compare/v2.2.3...v2.3.0)
|
6
|
+
|
7
|
+
**Closed issues:**
|
8
|
+
|
9
|
+
- \[SECURITY\] Algorithm Confusion Through kid Header [\#440](https://github.com/jwt/ruby-jwt/issues/440)
|
10
|
+
- JWT to memory [\#436](https://github.com/jwt/ruby-jwt/issues/436)
|
11
|
+
- ArgumentError: wrong number of arguments \(given 2, expected 1\) [\#429](https://github.com/jwt/ruby-jwt/issues/429)
|
12
|
+
- HMAC section of README outdated [\#421](https://github.com/jwt/ruby-jwt/issues/421)
|
13
|
+
- NoMethodError: undefined method `zero?' for nil:NilClass if JWT has no 'alg' field [\#410](https://github.com/jwt/ruby-jwt/issues/410)
|
14
|
+
- Release new version [\#409](https://github.com/jwt/ruby-jwt/issues/409)
|
15
|
+
- NameError: uninitialized constant JWT::JWK [\#403](https://github.com/jwt/ruby-jwt/issues/403)
|
16
|
+
|
17
|
+
**Merged pull requests:**
|
18
|
+
|
19
|
+
- Fix Style/MultilineIfModifier issues [\#447](https://github.com/jwt/ruby-jwt/pull/447) ([anakinj](https://github.com/anakinj))
|
20
|
+
- feat\(EdDSA\): Accept EdDSA as algorithm header [\#446](https://github.com/jwt/ruby-jwt/pull/446) ([Pierre-Michard](https://github.com/Pierre-Michard))
|
21
|
+
- Pass kid param through JWT::JWK.create\_from [\#445](https://github.com/jwt/ruby-jwt/pull/445) ([shaun-guth-allscripts](https://github.com/shaun-guth-allscripts))
|
22
|
+
- fix document about passing JWKs as a simple Hash [\#443](https://github.com/jwt/ruby-jwt/pull/443) ([takayamaki](https://github.com/takayamaki))
|
23
|
+
- Tests for mixing JWK keys with mismatching algorithms [\#441](https://github.com/jwt/ruby-jwt/pull/441) ([anakinj](https://github.com/anakinj))
|
24
|
+
- verify\_claims test shouldnt be within the verify\_sub test [\#431](https://github.com/jwt/ruby-jwt/pull/431) ([andyjdavis](https://github.com/andyjdavis))
|
25
|
+
- Allow decode options to specify required claims [\#430](https://github.com/jwt/ruby-jwt/pull/430) ([andyjdavis](https://github.com/andyjdavis))
|
26
|
+
- Fix OpenSSL::PKey::EC public\_key handing in tests [\#427](https://github.com/jwt/ruby-jwt/pull/427) ([anakinj](https://github.com/anakinj))
|
27
|
+
- Add documentation for find\_key [\#426](https://github.com/jwt/ruby-jwt/pull/426) ([ritikesh](https://github.com/ritikesh))
|
28
|
+
- Give ruby 3.0 as a string to avoid number formatting issues [\#424](https://github.com/jwt/ruby-jwt/pull/424) ([anakinj](https://github.com/anakinj))
|
29
|
+
- Tests for iat verification behaviour [\#423](https://github.com/jwt/ruby-jwt/pull/423) ([anakinj](https://github.com/anakinj))
|
30
|
+
- Remove HMAC with nil secret from documentation [\#422](https://github.com/jwt/ruby-jwt/pull/422) ([boardfish](https://github.com/boardfish))
|
31
|
+
- Update broken link in README [\#420](https://github.com/jwt/ruby-jwt/pull/420) ([severin](https://github.com/severin))
|
32
|
+
- Add metadata for RubyGems [\#418](https://github.com/jwt/ruby-jwt/pull/418) ([nickhammond](https://github.com/nickhammond))
|
33
|
+
- Fixed a typo about class name [\#417](https://github.com/jwt/ruby-jwt/pull/417) ([mai-f](https://github.com/mai-f))
|
34
|
+
- Fix references for v2.2.3 on CHANGELOG [\#416](https://github.com/jwt/ruby-jwt/pull/416) ([vyper](https://github.com/vyper))
|
35
|
+
- Raise IncorrectAlgorithm if token has no alg header [\#411](https://github.com/jwt/ruby-jwt/pull/411) ([bouk](https://github.com/bouk))
|
36
|
+
|
37
|
+
## [v2.2.3](https://github.com/jwt/ruby-jwt/tree/v2.2.3) (2021-04-19)
|
38
|
+
|
39
|
+
[Full Changelog](https://github.com/jwt/ruby-jwt/compare/v2.2.2...v2.2.3)
|
6
40
|
|
7
41
|
**Implemented enhancements:**
|
8
42
|
|
@@ -31,6 +65,7 @@
|
|
31
65
|
|
32
66
|
**Merged pull requests:**
|
33
67
|
|
68
|
+
- Prepare 2.2.3 release [\#415](https://github.com/jwt/ruby-jwt/pull/415) ([excpt](https://github.com/excpt))
|
34
69
|
- Remove codeclimate code coverage dev dependency [\#414](https://github.com/jwt/ruby-jwt/pull/414) ([excpt](https://github.com/excpt))
|
35
70
|
- Add forwardable dependency [\#408](https://github.com/jwt/ruby-jwt/pull/408) ([anakinj](https://github.com/anakinj))
|
36
71
|
- Ignore casing of algorithm [\#405](https://github.com/jwt/ruby-jwt/pull/405) ([johnnyshields](https://github.com/johnnyshields))
|
data/README.md
CHANGED
@@ -38,7 +38,7 @@ And run `bundle install`
|
|
38
38
|
|
39
39
|
## Algorithms and Usage
|
40
40
|
|
41
|
-
The JWT spec supports NONE, HMAC, RSASSA, ECDSA and RSASSA-PSS algorithms for cryptographic signing. Currently the jwt gem supports NONE, HMAC, RSASSA and ECDSA. If you are using cryptographic signing, you need to specify the algorithm in the options hash whenever you call JWT.decode to ensure that an attacker [cannot bypass the algorithm verification step](https://auth0.com/blog/
|
41
|
+
The JWT spec supports NONE, HMAC, RSASSA, ECDSA and RSASSA-PSS algorithms for cryptographic signing. Currently the jwt gem supports NONE, HMAC, RSASSA and ECDSA. If you are using cryptographic signing, you need to specify the algorithm in the options hash whenever you call JWT.decode to ensure that an attacker [cannot bypass the algorithm verification step](https://auth0.com/blog/critical-vulnerabilities-in-json-web-token-libraries/). **It is strongly recommended that you hard code the algorithm, as you may leave yourself vulnerable by dynamically picking the algorithm**
|
42
42
|
|
43
43
|
See: [ JSON Web Algorithms (JWA) 3.1. "alg" (Algorithm) Header Parameter Values for JWS](https://tools.ietf.org/html/rfc7518#section-3.1)
|
44
44
|
|
@@ -76,6 +76,7 @@ puts decoded_token
|
|
76
76
|
* HS512 - HMAC using SHA-512 hash algorithm
|
77
77
|
|
78
78
|
```ruby
|
79
|
+
# The secret must be a string. A JWT::DecodeError will be raised if it isn't provided.
|
79
80
|
hmac_secret = 'my$ecretK3y'
|
80
81
|
|
81
82
|
token = JWT.encode payload, hmac_secret, 'HS256'
|
@@ -85,21 +86,6 @@ puts token
|
|
85
86
|
|
86
87
|
decoded_token = JWT.decode token, hmac_secret, true, { algorithm: 'HS256' }
|
87
88
|
|
88
|
-
# Array
|
89
|
-
# [
|
90
|
-
# {"data"=>"test"}, # payload
|
91
|
-
# {"alg"=>"HS256"} # header
|
92
|
-
# ]
|
93
|
-
puts decoded_token
|
94
|
-
|
95
|
-
# Without secret key
|
96
|
-
token = JWT.encode payload, nil, 'HS256'
|
97
|
-
|
98
|
-
# eyJhbGciOiJIUzI1NiJ9.eyJkYXRhIjoidGVzdCJ9.pVzcY2dX8JNM3LzIYeP2B1e1Wcpt1K3TWVvIYSF4x-o
|
99
|
-
puts token
|
100
|
-
|
101
|
-
decoded_token = JWT.decode token, nil, true, { algorithm: 'HS256' }
|
102
|
-
|
103
89
|
# Array
|
104
90
|
# [
|
105
91
|
# {"data"=>"test"}, # payload
|
@@ -474,12 +460,42 @@ rescue JWT::InvalidSubError
|
|
474
460
|
end
|
475
461
|
```
|
476
462
|
|
463
|
+
### Finding a Key
|
464
|
+
|
465
|
+
To dynamically find the key for verifying the JWT signature, pass a block to the decode block. The block receives headers and the original payload as parameters. It should return with the key to verify the signature that was used to sign the JWT.
|
466
|
+
|
467
|
+
```ruby
|
468
|
+
issuers = %w[My_Awesome_Company1 My_Awesome_Company2]
|
469
|
+
iss_payload = { data: 'data', iss: issuers.first }
|
470
|
+
|
471
|
+
secrets = { issuers.first => hmac_secret, issuers.last => 'hmac_secret2' }
|
472
|
+
|
473
|
+
token = JWT.encode iss_payload, hmac_secret, 'HS256'
|
474
|
+
|
475
|
+
begin
|
476
|
+
# Add iss to the validation to check if the token has been manipulated
|
477
|
+
decoded_token = JWT.decode(token, nil, true, { iss: issuers, verify_iss: true, algorithm: 'HS256' }) do |_headers, payload|
|
478
|
+
secrets[payload['iss']]
|
479
|
+
end
|
480
|
+
rescue JWT::InvalidIssuerError
|
481
|
+
# Handle invalid token, e.g. logout user or deny access
|
482
|
+
end
|
483
|
+
```
|
484
|
+
|
485
|
+
### Required Claims
|
486
|
+
|
487
|
+
You can specify claims that must be present for decoding to be successful. JWT::MissingRequiredClaim will be raised if any are missing
|
488
|
+
```ruby
|
489
|
+
# Will raise a JWT::ExpiredSignature error if the 'exp' claim is absent
|
490
|
+
JWT.decode token, hmac_secret, true, { required_claims: ['exp'], algorithm: 'HS256' }
|
491
|
+
```
|
492
|
+
|
477
493
|
### JSON Web Key (JWK)
|
478
494
|
|
479
495
|
JWK is a JSON structure representing a cryptographic key. Currently only supports RSA public keys.
|
480
496
|
|
481
497
|
```ruby
|
482
|
-
jwk = JWT::JWK.new(OpenSSL::PKey::RSA.new(2048))
|
498
|
+
jwk = JWT::JWK.new(OpenSSL::PKey::RSA.new(2048), "optional-kid")
|
483
499
|
payload, headers = { data: 'data' }, { kid: jwk.kid }
|
484
500
|
|
485
501
|
token = JWT.encode(payload, jwk.keypair, 'RS512', headers)
|
@@ -502,7 +518,7 @@ end
|
|
502
518
|
or by passing JWK as a simple Hash
|
503
519
|
|
504
520
|
```
|
505
|
-
jwks = { keys: [{ ... }] } # keys
|
521
|
+
jwks = { keys: [{ ... }] } # keys accepts both of string and symbol
|
506
522
|
JWT.decode(token, nil, true, { algorithms: ['RS512'], jwks: jwks})
|
507
523
|
```
|
508
524
|
|
data/lib/jwt/algos/eddsa.rb
CHANGED
@@ -3,18 +3,25 @@ module JWT
|
|
3
3
|
module Eddsa
|
4
4
|
module_function
|
5
5
|
|
6
|
-
SUPPORTED = %w[ED25519].freeze
|
6
|
+
SUPPORTED = %w[ED25519 EdDSA].freeze
|
7
7
|
|
8
8
|
def sign(to_sign)
|
9
9
|
algorithm, msg, key = to_sign.values
|
10
|
-
|
11
|
-
|
10
|
+
if key.class != RbNaCl::Signatures::Ed25519::SigningKey
|
11
|
+
raise EncodeError, "Key given is a #{key.class} but has to be an RbNaCl::Signatures::Ed25519::SigningKey"
|
12
|
+
end
|
13
|
+
unless SUPPORTED.map(&:downcase).map(&:to_sym).include?(algorithm.downcase.to_sym)
|
14
|
+
raise IncorrectAlgorithm, "payload algorithm is #{algorithm} but #{key.primitive} signing key was provided"
|
15
|
+
end
|
16
|
+
|
12
17
|
key.sign(msg)
|
13
18
|
end
|
14
19
|
|
15
20
|
def verify(to_verify)
|
16
21
|
algorithm, public_key, signing_input, signature = to_verify.values
|
17
|
-
|
22
|
+
unless SUPPORTED.map(&:downcase).map(&:to_sym).include?(algorithm.downcase.to_sym)
|
23
|
+
raise IncorrectAlgorithm, "payload algorithm is #{algorithm} but #{key.primitive} signing key was provided"
|
24
|
+
end
|
18
25
|
raise DecodeError, "key given is a #{public_key.class} but has to be a RbNaCl::Signatures::Ed25519::VerifyKey" if public_key.class != RbNaCl::Signatures::Ed25519::VerifyKey
|
19
26
|
public_key.verify(signature, signing_input)
|
20
27
|
end
|
data/lib/jwt/decode.rb
CHANGED
@@ -34,6 +34,7 @@ module JWT
|
|
34
34
|
|
35
35
|
def verify_signature
|
36
36
|
raise(JWT::IncorrectAlgorithm, 'An algorithm must be specified') if allowed_algorithms.empty?
|
37
|
+
raise(JWT::IncorrectAlgorithm, 'Token is missing alg header') unless header['alg']
|
37
38
|
raise(JWT::IncorrectAlgorithm, 'Expected a different algorithm') unless options_includes_algo_in_header?
|
38
39
|
|
39
40
|
@key = find_key(&@keyfinder) if @keyfinder
|
@@ -70,6 +71,7 @@ module JWT
|
|
70
71
|
|
71
72
|
def verify_claims
|
72
73
|
Verify.verify_claims(payload, @options)
|
74
|
+
Verify.verify_required_claims(payload, @options)
|
73
75
|
end
|
74
76
|
|
75
77
|
def validate_segment_count!
|
data/lib/jwt/default_options.rb
CHANGED
data/lib/jwt/error.rb
CHANGED
data/lib/jwt/jwk/ec.rb
CHANGED
@@ -66,7 +66,7 @@ module JWT
|
|
66
66
|
crv = 'P-521'
|
67
67
|
x_octets, y_octets = encoded_point.unpack('xa66a66')
|
68
68
|
else
|
69
|
-
raise
|
69
|
+
raise JWT::JWKError, "Unsupported curve '#{ec_keypair.group.curve_name}'"
|
70
70
|
end
|
71
71
|
[crv, x_octets, y_octets]
|
72
72
|
end
|
@@ -85,7 +85,7 @@ module JWT
|
|
85
85
|
# explanation of the relevant parameters.
|
86
86
|
|
87
87
|
jwk_crv, jwk_x, jwk_y, jwk_d, jwk_kid = jwk_attrs(jwk_data, %i[crv x y d kid])
|
88
|
-
raise
|
88
|
+
raise JWT::JWKError, 'Key format is invalid for EC' unless jwk_crv && jwk_x && jwk_y
|
89
89
|
|
90
90
|
new(ec_pkey(jwk_crv, jwk_x, jwk_y, jwk_d), jwk_kid)
|
91
91
|
end
|
data/lib/jwt/jwk.rb
CHANGED
@@ -14,10 +14,10 @@ module JWT
|
|
14
14
|
end.import(jwk_data)
|
15
15
|
end
|
16
16
|
|
17
|
-
def create_from(keypair)
|
17
|
+
def create_from(keypair, kid = nil)
|
18
18
|
mappings.fetch(keypair.class) do |klass|
|
19
19
|
raise JWT::JWKError, "Cannot create JWK from a #{klass.name}"
|
20
|
-
end.new(keypair)
|
20
|
+
end.new(keypair, kid)
|
21
21
|
end
|
22
22
|
|
23
23
|
def classes
|
data/lib/jwt/verify.rb
CHANGED
@@ -10,7 +10,7 @@ module JWT
|
|
10
10
|
}.freeze
|
11
11
|
|
12
12
|
class << self
|
13
|
-
%w[verify_aud verify_expiration verify_iat verify_iss verify_jti verify_not_before verify_sub].each do |method_name|
|
13
|
+
%w[verify_aud verify_expiration verify_iat verify_iss verify_jti verify_not_before verify_sub verify_required_claims].each do |method_name|
|
14
14
|
define_method method_name do |payload, options|
|
15
15
|
new(payload, options).send(method_name)
|
16
16
|
end
|
@@ -81,6 +81,13 @@ module JWT
|
|
81
81
|
raise(JWT::InvalidSubError, "Invalid subject. Expected #{options_sub}, received #{sub || '<none>'}") unless sub.to_s == options_sub.to_s
|
82
82
|
end
|
83
83
|
|
84
|
+
def verify_required_claims
|
85
|
+
return unless (options_required_claims = @options[:required_claims])
|
86
|
+
options_required_claims.each do |required_claim|
|
87
|
+
raise(JWT::MissingRequiredClaim, "Missing required claim #{required_claim}") unless @payload.include?(required_claim)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
84
91
|
private
|
85
92
|
|
86
93
|
def global_leeway
|
data/lib/jwt/version.rb
CHANGED
data/ruby-jwt.gemspec
CHANGED
@@ -14,6 +14,10 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.homepage = 'https://github.com/jwt/ruby-jwt'
|
15
15
|
spec.license = 'MIT'
|
16
16
|
spec.required_ruby_version = '>= 2.1'
|
17
|
+
spec.metadata = {
|
18
|
+
'bug_tracker_uri' => 'https://github.com/jwt/ruby-jwt/issues',
|
19
|
+
'changelog_uri' => "https://github.com/jwt/ruby-jwt/blob/v#{JWT.gem_version}/CHANGELOG.md"
|
20
|
+
}
|
17
21
|
|
18
22
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(spec|gemfiles|coverage|bin)/}) }
|
19
23
|
spec.executables = []
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jwt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Rudat
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: appraisal
|
@@ -130,7 +130,9 @@ files:
|
|
130
130
|
homepage: https://github.com/jwt/ruby-jwt
|
131
131
|
licenses:
|
132
132
|
- MIT
|
133
|
-
metadata:
|
133
|
+
metadata:
|
134
|
+
bug_tracker_uri: https://github.com/jwt/ruby-jwt/issues
|
135
|
+
changelog_uri: https://github.com/jwt/ruby-jwt/blob/v2.3.0/CHANGELOG.md
|
134
136
|
post_install_message:
|
135
137
|
rdoc_options: []
|
136
138
|
require_paths:
|
@@ -146,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
146
148
|
- !ruby/object:Gem::Version
|
147
149
|
version: '0'
|
148
150
|
requirements: []
|
149
|
-
rubygems_version: 3.2.
|
151
|
+
rubygems_version: 3.2.19
|
150
152
|
signing_key:
|
151
153
|
specification_version: 4
|
152
154
|
summary: JSON Web Token implementation in Ruby
|