jwt 3.0.0.beta1 → 3.0.0

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: 30b9373b7591af7e5e8ba0f049a2d41bc87afe0ea21462bd011f9558ec45e892
4
- data.tar.gz: d5e77784a5eda9bae03f7bed74dabcfa81db1720057f742787c723d679d1005c
3
+ metadata.gz: 8bc851245c9a662d91209f426033dc2b2521de4cd07f11529aa34c0e69ad9201
4
+ data.tar.gz: fa9ae48864cb04df26a6e003e90430b1dcf85ad4ba1da707ea688b6efd43b9b4
5
5
  SHA512:
6
- metadata.gz: eafdd62f2eb9c35d2a27bf0429a866dd6f54b56c2650c373185f1c3e53ce08e06d03e5d8baba934493ea615cc9b86038d93a634509e5d932fdcbc91d669310e9
7
- data.tar.gz: 68b004a6d858e2bfb78ba41017b19ec37b0dbed43525f63b9a743111f6d2f26eb4aea7a61ff2d2774645c504021d34ee8296cf342f36af97c426e96690ec08d7
6
+ metadata.gz: 26e15ad0fa03a06b830b380d74b2efbc23a85ecdc8f3a72b1d938706622c83d28217167e87eec73c7633dfc0ee3656c0c2d2ba4fd604cedb1289cc36d730706c
7
+ data.tar.gz: 0076ad48c7dcc3ddc3fa55b776ca4566452c17aae211af36616634429e37fd687fb29fcf5e0fea5ee32945fe2359784f2ee48535a76509f90813dfe481892394
data/CHANGELOG.md CHANGED
@@ -1,10 +1,11 @@
1
1
  # Changelog
2
2
 
3
- ## [v3.0.0](https://github.com/jwt/ruby-jwt/tree/v3.0.0) (NEXT)
3
+ ## [v3.0.0](https://github.com/jwt/ruby-jwt/tree/v3.0.0) (2025-06-14)
4
4
 
5
- [Full Changelog](https://github.com/jwt/ruby-jwt/compare/v2.10.1...main)
5
+ [Full Changelog](https://github.com/jwt/ruby-jwt/compare/v2.10.1...v3.0.0)
6
6
 
7
7
  **Breaking changes:**
8
+
8
9
  - Require token signature to be verified before accessing payload [#648](https://github.com/jwt/ruby-jwt/pull/648) ([@anakinj](https://github.com/anakinj))
9
10
  - Drop support for the HS512256 algorithm [#650](https://github.com/jwt/ruby-jwt/pull/650) ([@anakinj](https://github.com/anakinj))
10
11
  - Remove deprecated claim verification methods [#654](https://github.com/jwt/ruby-jwt/pull/654) ([@anakinj](https://github.com/anakinj))
@@ -17,15 +18,15 @@
17
18
  Take a look at the [upgrade guide](UPGRADING.md) for more details.
18
19
 
19
20
  **Features:**
21
+
20
22
  - JWT::EncodedToken#verify! method that bundles signature and claim validation [#647](https://github.com/jwt/ruby-jwt/pull/647) ([@anakinj](https://github.com/anakinj))
21
23
  - Do not override the alg header if already given [#659](https://github.com/jwt/ruby-jwt/pull/659) ([@anakinj](https://github.com/anakinj))
22
24
  - Make `JWK::KeyFinder` compatible with `JWT::EncodedToken` [#663](https://github.com/jwt/ruby-jwt/pull/663) ([@anakinj](https://github.com/anakinj))
23
- - Your contribution here
24
25
 
25
26
  **Fixes and enhancements:**
26
27
 
27
28
  - Ruby 3.4 to CI matrix [#649](https://github.com/jwt/ruby-jwt/pull/649) ([@anakinj](https://github.com/anakinj))
28
- - Your contribution here
29
+ - Add logger as development dependency [#670](https://github.com/jwt/ruby-jwt/pull/670) ([@hieuk09](https://github.com/hieuk09))
29
30
 
30
31
  ## [v2.10.1](https://github.com/jwt/ruby-jwt/tree/v2.10.1) (2024-12-26)
31
32
 
@@ -189,6 +190,7 @@ Take a look at the [upgrade guide](UPGRADING.md) for more details.
189
190
  - Support OpenSSL >= 3.0 [#496](https://github.com/jwt/ruby-jwt/pull/496) ([@anakinj](https://github.com/anakinj))
190
191
 
191
192
  **Fixes and enhancements:**
193
+
192
194
  - Bring back the old Base64 (RFC2045) deocode mechanisms [#488](https://github.com/jwt/ruby-jwt/pull/488) ([@anakinj](https://github.com/anakinj))
193
195
  - Rescue RbNaCl exception for EdDSA wrong key [#491](https://github.com/jwt/ruby-jwt/pull/491) ([@n-studio](https://github.com/n-studio))
194
196
  - New parameter name for cases when kid is not found using JWK key loader proc [#501](https://github.com/jwt/ruby-jwt/pull/501) ([@anakinj](https://github.com/anakinj))
@@ -199,6 +201,7 @@ Take a look at the [upgrade guide](UPGRADING.md) for more details.
199
201
  [Full Changelog](https://github.com/jwt/ruby-jwt/compare/v2.4.0...v2.4.1)
200
202
 
201
203
  **Fixes and enhancements:**
204
+
202
205
  - Raise JWT::DecodeError on invalid signature [\#484](https://github.com/jwt/ruby-jwt/pull/484) ([@freakyfelt!](https://github.com/freakyfelt!))
203
206
 
204
207
  ## [v2.4.0](https://github.com/jwt/ruby-jwt/tree/v2.4.0) (2022-06-06)
@@ -216,11 +219,12 @@ Take a look at the [upgrade guide](UPGRADING.md) for more details.
216
219
  - Add Support to be able to verify from multiple keys [\#425](https://github.com/jwt/ruby-jwt/pull/425) ([ritikesh](https://github.com/ritikesh))
217
220
 
218
221
  **Fixes and enhancements:**
222
+
219
223
  - Readme: Typo fix re MissingRequiredClaim [\#451](https://github.com/jwt/ruby-jwt/pull/451) ([antonmorant](https://github.com/antonmorant))
220
224
  - Fix RuboCop TODOs [\#476](https://github.com/jwt/ruby-jwt/pull/476) ([typhoon2099](https://github.com/typhoon2099))
221
225
  - Make specific algorithms in README linkable [\#472](https://github.com/jwt/ruby-jwt/pull/472) ([milieu](https://github.com/milieu))
222
226
  - Update note about supported JWK types [\#475](https://github.com/jwt/ruby-jwt/pull/475) ([dpashkevich](https://github.com/dpashkevich))
223
- - Create CODE\_OF\_CONDUCT.md [\#449](https://github.com/jwt/ruby-jwt/pull/449) ([loic5](https://github.com/loic5))
227
+ - Create CODE_OF_CONDUCT.md [\#449](https://github.com/jwt/ruby-jwt/pull/449) ([loic5](https://github.com/loic5))
224
228
 
225
229
  ## [v2.3.0](https://github.com/jwt/ruby-jwt/tree/v2.3.0) (2021-10-03)
226
230
 
@@ -241,19 +245,19 @@ Take a look at the [upgrade guide](UPGRADING.md) for more details.
241
245
  - Release 2.3.0 [\#448](https://github.com/jwt/ruby-jwt/pull/448) ([excpt](https://github.com/excpt))
242
246
  - Fix Style/MultilineIfModifier issues [\#447](https://github.com/jwt/ruby-jwt/pull/447) ([anakinj](https://github.com/anakinj))
243
247
  - feat\(EdDSA\): Accept EdDSA as algorithm header [\#446](https://github.com/jwt/ruby-jwt/pull/446) ([Pierre-Michard](https://github.com/Pierre-Michard))
244
- - 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))
248
+ - 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))
245
249
  - fix document about passing JWKs as a simple Hash [\#443](https://github.com/jwt/ruby-jwt/pull/443) ([takayamaki](https://github.com/takayamaki))
246
250
  - Tests for mixing JWK keys with mismatching algorithms [\#441](https://github.com/jwt/ruby-jwt/pull/441) ([anakinj](https://github.com/anakinj))
247
- - verify\_claims test shouldnt be within the verify\_sub test [\#431](https://github.com/jwt/ruby-jwt/pull/431) ([andyjdavis](https://github.com/andyjdavis))
251
+ - verify_claims test shouldnt be within the verify_sub test [\#431](https://github.com/jwt/ruby-jwt/pull/431) ([andyjdavis](https://github.com/andyjdavis))
248
252
  - Allow decode options to specify required claims [\#430](https://github.com/jwt/ruby-jwt/pull/430) ([andyjdavis](https://github.com/andyjdavis))
249
- - Fix OpenSSL::PKey::EC public\_key handing in tests [\#427](https://github.com/jwt/ruby-jwt/pull/427) ([anakinj](https://github.com/anakinj))
250
- - Add documentation for find\_key [\#426](https://github.com/jwt/ruby-jwt/pull/426) ([ritikesh](https://github.com/ritikesh))
253
+ - Fix OpenSSL::PKey::EC public_key handing in tests [\#427](https://github.com/jwt/ruby-jwt/pull/427) ([anakinj](https://github.com/anakinj))
254
+ - Add documentation for find_key [\#426](https://github.com/jwt/ruby-jwt/pull/426) ([ritikesh](https://github.com/ritikesh))
251
255
  - 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))
252
256
  - Tests for iat verification behaviour [\#423](https://github.com/jwt/ruby-jwt/pull/423) ([anakinj](https://github.com/anakinj))
253
257
  - Remove HMAC with nil secret from documentation [\#422](https://github.com/jwt/ruby-jwt/pull/422) ([boardfish](https://github.com/boardfish))
254
258
  - Update broken link in README [\#420](https://github.com/jwt/ruby-jwt/pull/420) ([severin](https://github.com/severin))
255
259
  - Add metadata for RubyGems [\#418](https://github.com/jwt/ruby-jwt/pull/418) ([nickhammond](https://github.com/nickhammond))
256
- - Fixed a typo about class name [\#417](https://github.com/jwt/ruby-jwt/pull/417) ([mai-f](https://github.com/mai-f))
260
+ - Fixed a typo about class name [\#417](https://github.com/jwt/ruby-jwt/pull/417) ([mai-f](https://github.com/mai-f))
257
261
  - Fix references for v2.2.3 on CHANGELOG [\#416](https://github.com/jwt/ruby-jwt/pull/416) ([vyper](https://github.com/vyper))
258
262
  - Raise IncorrectAlgorithm if token has no alg header [\#411](https://github.com/jwt/ruby-jwt/pull/411) ([bouk](https://github.com/bouk))
259
263
 
@@ -263,9 +267,9 @@ Take a look at the [upgrade guide](UPGRADING.md) for more details.
263
267
 
264
268
  **Implemented enhancements:**
265
269
 
266
- - Verify algorithm before evaluating keyfinder [\#343](https://github.com/jwt/ruby-jwt/issues/343)
270
+ - Verify algorithm before evaluating keyfinder [\#343](https://github.com/jwt/ruby-jwt/issues/343)
267
271
  - Why jwt depends on json \< 2.0 ? [\#179](https://github.com/jwt/ruby-jwt/issues/179)
268
- - Support for JWK in-lieu of rsa\_public [\#158](https://github.com/jwt/ruby-jwt/issues/158)
272
+ - Support for JWK in-lieu of rsa_public [\#158](https://github.com/jwt/ruby-jwt/issues/158)
269
273
  - Fix rspec `raise_error` warning [\#413](https://github.com/jwt/ruby-jwt/pull/413) ([excpt](https://github.com/excpt))
270
274
  - Add support for JWKs with HMAC key type. [\#372](https://github.com/jwt/ruby-jwt/pull/372) ([phlegx](https://github.com/phlegx))
271
275
  - Improve 'none' algorithm handling [\#365](https://github.com/jwt/ruby-jwt/pull/365) ([danleyden](https://github.com/danleyden))
@@ -293,7 +297,7 @@ Take a look at the [upgrade guide](UPGRADING.md) for more details.
293
297
  - Add forwardable dependency [\#408](https://github.com/jwt/ruby-jwt/pull/408) ([anakinj](https://github.com/anakinj))
294
298
  - Ignore casing of algorithm [\#405](https://github.com/jwt/ruby-jwt/pull/405) ([johnnyshields](https://github.com/johnnyshields))
295
299
  - Document function and add tests for verify claims method [\#404](https://github.com/jwt/ruby-jwt/pull/404) ([yasonk](https://github.com/yasonk))
296
- - documenting calling verify\_jti callback with 2 arguments in the readme [\#402](https://github.com/jwt/ruby-jwt/pull/402) ([HoneyryderChuck](https://github.com/HoneyryderChuck))
300
+ - documenting calling verify_jti callback with 2 arguments in the readme [\#402](https://github.com/jwt/ruby-jwt/pull/402) ([HoneyryderChuck](https://github.com/HoneyryderChuck))
297
301
  - Target the master branch on the build status badge [\#399](https://github.com/jwt/ruby-jwt/pull/399) ([anakinj](https://github.com/anakinj))
298
302
  - Improving the local development experience [\#397](https://github.com/jwt/ruby-jwt/pull/397) ([anakinj](https://github.com/anakinj))
299
303
  - Fix sourcelevel broken links [\#395](https://github.com/jwt/ruby-jwt/pull/395) ([anakinj](https://github.com/anakinj))
@@ -341,7 +345,7 @@ Take a look at the [upgrade guide](UPGRADING.md) for more details.
341
345
  - Decode any token [\#360](https://github.com/jwt/ruby-jwt/issues/360)
342
346
  - \[question\] example of using a pub/priv keys for signing? [\#351](https://github.com/jwt/ruby-jwt/issues/351)
343
347
  - JWT::ExpiredSignature raised for non-JSON payloads [\#350](https://github.com/jwt/ruby-jwt/issues/350)
344
- - verify\_aud only verifies that at least one aud is expected [\#345](https://github.com/jwt/ruby-jwt/issues/345)
348
+ - verify_aud only verifies that at least one aud is expected [\#345](https://github.com/jwt/ruby-jwt/issues/345)
345
349
  - Sinatra 4.90s TTFB [\#344](https://github.com/jwt/ruby-jwt/issues/344)
346
350
  - How to Logout [\#342](https://github.com/jwt/ruby-jwt/issues/342)
347
351
  - jwt token decoding even when wrong token is provided for some letters [\#337](https://github.com/jwt/ruby-jwt/issues/337)
@@ -393,9 +397,9 @@ Take a look at the [upgrade guide](UPGRADING.md) for more details.
393
397
 
394
398
  **Implemented enhancements:**
395
399
 
396
- - Use iat\_leeway option [\#273](https://github.com/jwt/ruby-jwt/issues/273)
400
+ - Use iat_leeway option [\#273](https://github.com/jwt/ruby-jwt/issues/273)
397
401
  - Use of global state in latest version breaks thread safety of JWT.decode [\#268](https://github.com/jwt/ruby-jwt/issues/268)
398
- - JSON support [\#246](https://github.com/jwt/ruby-jwt/issues/246)
402
+ - JSON support [\#246](https://github.com/jwt/ruby-jwt/issues/246)
399
403
  - Change the Github homepage URL to https [\#301](https://github.com/jwt/ruby-jwt/pull/301) ([ekohl](https://github.com/ekohl))
400
404
  - Fix Salt length for conformance with PS family specification. [\#300](https://github.com/jwt/ruby-jwt/pull/300) ([tobypinder](https://github.com/tobypinder))
401
405
  - Add support for Ruby 2.6 [\#299](https://github.com/jwt/ruby-jwt/pull/299) ([bustikiller](https://github.com/bustikiller))
@@ -408,7 +412,7 @@ Take a look at the [upgrade guide](UPGRADING.md) for more details.
408
412
  - Add note about using a hard coded algorithm in README [\#280](https://github.com/jwt/ruby-jwt/pull/280) ([revodoge](https://github.com/revodoge))
409
413
  - Add Appraisal support [\#278](https://github.com/jwt/ruby-jwt/pull/278) ([olbrich](https://github.com/olbrich))
410
414
  - Fix decode threading issue [\#269](https://github.com/jwt/ruby-jwt/pull/269) ([ab320012](https://github.com/ab320012))
411
- - Removed leeway from verify\_iat [\#257](https://github.com/jwt/ruby-jwt/pull/257) ([ab320012](https://github.com/ab320012))
415
+ - Removed leeway from verify_iat [\#257](https://github.com/jwt/ruby-jwt/pull/257) ([ab320012](https://github.com/ab320012))
412
416
 
413
417
  **Fixed bugs:**
414
418
 
@@ -438,7 +442,7 @@ Take a look at the [upgrade guide](UPGRADING.md) for more details.
438
442
  - Infer algorithm from header [\#254](https://github.com/jwt/ruby-jwt/issues/254)
439
443
  - Why is the result of decode is an array? [\#252](https://github.com/jwt/ruby-jwt/issues/252)
440
444
  - Add support for headless token [\#251](https://github.com/jwt/ruby-jwt/issues/251)
441
- - Leeway or exp\_leeway [\#215](https://github.com/jwt/ruby-jwt/issues/215)
445
+ - Leeway or exp_leeway [\#215](https://github.com/jwt/ruby-jwt/issues/215)
442
446
  - Could you describe purpose of cert fixtures and their cryptokey lengths. [\#185](https://github.com/jwt/ruby-jwt/issues/185)
443
447
 
444
448
  **Merged pull requests:**
@@ -449,7 +453,7 @@ Take a look at the [upgrade guide](UPGRADING.md) for more details.
449
453
  - Drop Ruby 2.2 from test matrix [\#290](https://github.com/jwt/ruby-jwt/pull/290) ([anakinj](https://github.com/anakinj))
450
454
  - Remove broken reek config [\#283](https://github.com/jwt/ruby-jwt/pull/283) ([excpt](https://github.com/excpt))
451
455
  - Add missing test, Update common files [\#275](https://github.com/jwt/ruby-jwt/pull/275) ([excpt](https://github.com/excpt))
452
- - Remove iat\_leeway option [\#274](https://github.com/jwt/ruby-jwt/pull/274) ([wohlgejm](https://github.com/wohlgejm))
456
+ - Remove iat_leeway option [\#274](https://github.com/jwt/ruby-jwt/pull/274) ([wohlgejm](https://github.com/wohlgejm))
453
457
  - improving code quality of jwt module [\#266](https://github.com/jwt/ruby-jwt/pull/266) ([ab320012](https://github.com/ab320012))
454
458
  - fixed ECDSA supported versions const [\#263](https://github.com/jwt/ruby-jwt/pull/263) ([starbeast](https://github.com/starbeast))
455
459
  - Added my name to contributor list [\#262](https://github.com/jwt/ruby-jwt/pull/262) ([ab320012](https://github.com/ab320012))
@@ -539,14 +543,14 @@ Take a look at the [upgrade guide](UPGRADING.md) for more details.
539
543
  - Move signature logic to its own module [\#195](https://github.com/jwt/ruby-jwt/pull/195) ([EmilioCristalli](https://github.com/EmilioCristalli))
540
544
  - Add options for claim-specific leeway [\#187](https://github.com/jwt/ruby-jwt/pull/187) ([EmilioCristalli](https://github.com/EmilioCristalli))
541
545
  - Add user friendly encode error if private key is a String, \#171 [\#176](https://github.com/jwt/ruby-jwt/pull/176) ([ogonki-vetochki](https://github.com/ogonki-vetochki))
542
- - Return empty string if signature less than byte\_size \#155 [\#175](https://github.com/jwt/ruby-jwt/pull/175) ([ogonki-vetochki](https://github.com/ogonki-vetochki))
546
+ - Return empty string if signature less than byte_size \#155 [\#175](https://github.com/jwt/ruby-jwt/pull/175) ([ogonki-vetochki](https://github.com/ogonki-vetochki))
543
547
  - Remove 'typ' optional parameter [\#174](https://github.com/jwt/ruby-jwt/pull/174) ([ogonki-vetochki](https://github.com/ogonki-vetochki))
544
548
  - Pass payload to keyfinder [\#172](https://github.com/jwt/ruby-jwt/pull/172) ([CodeMonkeySteve](https://github.com/CodeMonkeySteve))
545
549
  - Use RbNaCl for HMAC if available with fallback to OpenSSL [\#149](https://github.com/jwt/ruby-jwt/pull/149) ([mwpastore](https://github.com/mwpastore))
546
550
 
547
551
  **Fixed bugs:**
548
552
 
549
- - ruby-jwt::raw\_to\_asn1: Fails for signatures less than byte\_size [\#155](https://github.com/jwt/ruby-jwt/issues/155)
553
+ - ruby-jwt::raw_to_asn1: Fails for signatures less than byte_size [\#155](https://github.com/jwt/ruby-jwt/issues/155)
550
554
  - The leeway parameter is applies to all time based verifications [\#129](https://github.com/jwt/ruby-jwt/issues/129)
551
555
  - Make algorithm option required to verify signature [\#184](https://github.com/jwt/ruby-jwt/pull/184) ([EmilioCristalli](https://github.com/EmilioCristalli))
552
556
  - Validate audience when payload is a scalar and options is an array [\#183](https://github.com/jwt/ruby-jwt/pull/183) ([steti](https://github.com/steti))
@@ -558,7 +562,7 @@ Take a look at the [upgrade guide](UPGRADING.md) for more details.
558
562
  - Include custom headers with password [\#189](https://github.com/jwt/ruby-jwt/issues/189)
559
563
  - can't create token - 'NotImplementedError: Unsupported signing method' [\#186](https://github.com/jwt/ruby-jwt/issues/186)
560
564
  - Cannot verify JWT at all?? [\#177](https://github.com/jwt/ruby-jwt/issues/177)
561
- - verify\_iss: true is raising JWT::DecodeError instead of JWT::InvalidIssuerError [\#170](https://github.com/jwt/ruby-jwt/issues/170)
565
+ - verify_iss: true is raising JWT::DecodeError instead of JWT::InvalidIssuerError [\#170](https://github.com/jwt/ruby-jwt/issues/170)
562
566
 
563
567
  **Merged pull requests:**
564
568
 
@@ -629,7 +633,7 @@ Take a look at the [upgrade guide](UPGRADING.md) for more details.
629
633
  - Added test execution to Rakefile [\#147](https://github.com/jwt/ruby-jwt/pull/147) ([jabbrwcky](https://github.com/jabbrwcky))
630
634
  - Bump version [\#145](https://github.com/jwt/ruby-jwt/pull/145) ([excpt](https://github.com/excpt))
631
635
  - Add a changelog file [\#142](https://github.com/jwt/ruby-jwt/pull/142) ([excpt](https://github.com/excpt))
632
- - Return decoded\_segments [\#139](https://github.com/jwt/ruby-jwt/pull/139) ([akostrikov](https://github.com/akostrikov))
636
+ - Return decoded_segments [\#139](https://github.com/jwt/ruby-jwt/pull/139) ([akostrikov](https://github.com/akostrikov))
633
637
 
634
638
  ## [v1.5.4](https://github.com/jwt/ruby-jwt/tree/v1.5.4) (2016-03-24)
635
639
 
@@ -637,12 +641,12 @@ Take a look at the [upgrade guide](UPGRADING.md) for more details.
637
641
 
638
642
  **Closed issues:**
639
643
 
640
- - 404 at https://rubygems.global.ssl.fastly.net/gems/jwt-1.5.3.gem [\#137](https://github.com/jwt/ruby-jwt/issues/137)
644
+ - 404 at [https://rubygems.global.ssl.fastly.net/gems/jwt-1.5.3.gem](https://rubygems.global.ssl.fastly.net/gems/jwt-1.5.3.gem) [\#137](https://github.com/jwt/ruby-jwt/issues/137)
641
645
 
642
646
  **Merged pull requests:**
643
647
 
644
648
  - Update README.md [\#138](https://github.com/jwt/ruby-jwt/pull/138) ([excpt](https://github.com/excpt))
645
- - Fix base64url\_decode [\#136](https://github.com/jwt/ruby-jwt/pull/136) ([excpt](https://github.com/excpt))
649
+ - Fix base64url_decode [\#136](https://github.com/jwt/ruby-jwt/pull/136) ([excpt](https://github.com/excpt))
646
650
  - Fix ruby 1.9.3 compatibility [\#135](https://github.com/jwt/ruby-jwt/pull/135) ([excpt](https://github.com/excpt))
647
651
  - iat can be a float value [\#134](https://github.com/jwt/ruby-jwt/pull/134) ([llimllib](https://github.com/llimllib))
648
652
 
@@ -663,7 +667,7 @@ Take a look at the [upgrade guide](UPGRADING.md) for more details.
663
667
  - Verifications not functioning in latest release [\#128](https://github.com/jwt/ruby-jwt/issues/128)
664
668
  - Base64 is generating invalid length base64 strings - cross language interop [\#127](https://github.com/jwt/ruby-jwt/issues/127)
665
669
  - Digest::Digest is deprecated; use Digest [\#119](https://github.com/jwt/ruby-jwt/issues/119)
666
- - verify\_rsa no method 'verify' for class String [\#115](https://github.com/jwt/ruby-jwt/issues/115)
670
+ - verify_rsa no method 'verify' for class String [\#115](https://github.com/jwt/ruby-jwt/issues/115)
667
671
  - Add a changelog [\#111](https://github.com/jwt/ruby-jwt/issues/111)
668
672
 
669
673
  **Merged pull requests:**
@@ -781,14 +785,14 @@ Take a look at the [upgrade guide](UPGRADING.md) for more details.
781
785
 
782
786
  **Closed issues:**
783
787
 
784
- - The behavior using 'json' differs from 'multi\_json' [\#41](https://github.com/jwt/ruby-jwt/issues/41)
788
+ - The behavior using 'json' differs from 'multi_json' [\#41](https://github.com/jwt/ruby-jwt/issues/41)
785
789
 
786
790
  **Merged pull requests:**
787
791
 
788
792
  - Release 1.4.0 [\#64](https://github.com/jwt/ruby-jwt/pull/64) ([excpt](https://github.com/excpt))
789
793
  - Update README.md and remove dead code [\#63](https://github.com/jwt/ruby-jwt/pull/63) ([excpt](https://github.com/excpt))
790
- - Add 'iat/ aud/ sub/ jti' support for ruby-jwt [\#62](https://github.com/jwt/ruby-jwt/pull/62) ([ZhangHanDong](https://github.com/ZhangHanDong))
791
- - Add 'iss' support for ruby-jwt [\#61](https://github.com/jwt/ruby-jwt/pull/61) ([ZhangHanDong](https://github.com/ZhangHanDong))
794
+ - Add 'iat/ aud/ sub/ jti' support for ruby-jwt [\#62](https://github.com/jwt/ruby-jwt/pull/62) ([ZhangHanDong](https://github.com/ZhangHanDong))
795
+ - Add 'iss' support for ruby-jwt [\#61](https://github.com/jwt/ruby-jwt/pull/61) ([ZhangHanDong](https://github.com/ZhangHanDong))
792
796
  - Clarify .encode API in README [\#60](https://github.com/jwt/ruby-jwt/pull/60) ([jbodah](https://github.com/jbodah))
793
797
 
794
798
  ## [jwt-1.3.0](https://github.com/jwt/ruby-jwt/tree/jwt-1.3.0) (2015-02-24)
@@ -851,7 +855,7 @@ Take a look at the [upgrade guide](UPGRADING.md) for more details.
851
855
 
852
856
  **Closed issues:**
853
857
 
854
- - API request - JWT::decoded\_header\(\) [\#26](https://github.com/jwt/ruby-jwt/issues/26)
858
+ - API request - JWT::decoded_header\(\) [\#26](https://github.com/jwt/ruby-jwt/issues/26)
855
859
 
856
860
  **Merged pull requests:**
857
861
 
@@ -954,9 +958,5 @@ Take a look at the [upgrade guide](UPGRADING.md) for more details.
954
958
 
955
959
  **Merged pull requests:**
956
960
 
957
- - Bumped a version and added a .gemspec using rake build\_gemspec [\#3](https://github.com/jwt/ruby-jwt/pull/3) ([zhitomirskiyi](https://github.com/zhitomirskiyi))
961
+ - Bumped a version and added a .gemspec using rake build_gemspec [\#3](https://github.com/jwt/ruby-jwt/pull/3) ([zhitomirskiyi](https://github.com/zhitomirskiyi))
958
962
  - Added RSA support [\#2](https://github.com/jwt/ruby-jwt/pull/2) ([zhitomirskiyi](https://github.com/zhitomirskiyi))
959
-
960
-
961
-
962
- \* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
data/CODE_OF_CONDUCT.md CHANGED
@@ -10,21 +10,21 @@ We pledge to act and interact in ways that contribute to an open, welcoming, div
10
10
 
11
11
  Examples of behavior that contributes to a positive environment for our community include:
12
12
 
13
- * Demonstrating empathy and kindness toward other people
14
- * Being respectful of differing opinions, viewpoints, and experiences
15
- * Giving and gracefully accepting constructive feedback
16
- * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
- * Focusing on what is best not just for us as individuals, but for the overall community
13
+ - Demonstrating empathy and kindness toward other people
14
+ - Being respectful of differing opinions, viewpoints, and experiences
15
+ - Giving and gracefully accepting constructive feedback
16
+ - Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ - Focusing on what is best not just for us as individuals, but for the overall community
18
18
 
19
19
  Examples of unacceptable behavior include:
20
20
 
21
- * The use of sexualized language or imagery, and sexual attention or
21
+ - The use of sexualized language or imagery, and sexual attention or
22
22
  advances of any kind
23
- * Trolling, insulting or derogatory comments, and personal or political attacks
24
- * Public or private harassment
25
- * Publishing others' private information, such as a physical or email
23
+ - Trolling, insulting or derogatory comments, and personal or political attacks
24
+ - Public or private harassment
25
+ - Publishing others' private information, such as a physical or email
26
26
  address, without their explicit permission
27
- * Other conduct which could reasonably be considered inappropriate in a
27
+ - Other conduct which could reasonably be considered inappropriate in a
28
28
  professional setting
29
29
 
30
30
  ## Enforcement Responsibilities
@@ -39,7 +39,7 @@ This Code of Conduct applies within all community spaces, and also applies when
39
39
 
40
40
  ## Enforcement
41
41
 
42
- Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at antmanj@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at <antmanj@gmail.com>. All complaints will be reviewed and investigated promptly and fairly.
43
43
 
44
44
  All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
45
 
@@ -67,18 +67,18 @@ Community leaders will follow these Community Impact Guidelines in determining t
67
67
 
68
68
  ### 4. Permanent Ban
69
69
 
70
- **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
71
 
72
72
  **Consequence**: A permanent ban from any sort of public interaction within the community.
73
73
 
74
74
  ## Attribution
75
75
 
76
76
  This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
- available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
77
+ available at [https://www.contributor-covenant.org/version/2/0/code_of_conduct.html](https://www.contributor-covenant.org/version/2/0/code_of_conduct.html).
78
78
 
79
79
  Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
80
 
81
81
  [homepage]: https://www.contributor-covenant.org
82
82
 
83
83
  For answers to common questions about this code of conduct, see the FAQ at
84
- https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
84
+ [https://www.contributor-covenant.org/faq](https://www.contributor-covenant.org/faq). Translations are available at [https://www.contributor-covenant.org/translations](https://www.contributor-covenant.org/translations).
data/CONTRIBUTING.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  Fork the project on GitHub and clone your own fork. Instuctions on forking can be found from the [GitHub Docs](https://docs.github.com/en/get-started/quickstart/fork-a-repo)
6
6
 
7
- ```
7
+ ```bash
8
8
  git clone git@github.com:you/ruby-jwt.git
9
9
  cd ruby-jwt
10
10
  git remote add upstream https://github.com/jwt/ruby-jwt
@@ -14,7 +14,7 @@ git remote add upstream https://github.com/jwt/ruby-jwt
14
14
 
15
15
  Make sure you have the latest upstream main branch of the project.
16
16
 
17
- ```
17
+ ```bash
18
18
  git fetch --all
19
19
  git checkout main
20
20
  git rebase upstream/main
@@ -44,7 +44,8 @@ Implement tests and your change. Don't be shy adding a little something in the [
44
44
  Add a short description of the change in either the `Features` or `Fixes` section in the [CHANGELOG](CHANGELOG.md) file.
45
45
 
46
46
  The form of the row (You need to return to the row when you know the pull request id)
47
- ```
47
+
48
+ ```markdown
48
49
  - Fix a little problem [#123](https://github.com/jwt/ruby-jwt/pull/123) - [@you](https://github.com/you).
49
50
  ```
50
51
 
@@ -52,7 +53,7 @@ The form of the row (You need to return to the row when you know the pull reques
52
53
 
53
54
  Before pushing make sure the tests pass and RuboCop is happy.
54
55
 
55
- ```
56
+ ```bash
56
57
  bundle exec appraisal rake test
57
58
  bundle exec rubocop
58
59
  git push origin fix-a-little-problem
@@ -64,9 +65,9 @@ Make a new pull request on the [ruby-jwt project](https://github.com/jwt/ruby-jw
64
65
 
65
66
  Update the [CHANGELOG](CHANGELOG.md) with the pull request id from the previous step.
66
67
 
67
- You can ammend the previous commit with the updated changelog change and force push your branch. The PR will get automatically updated.
68
+ You can amend the previous commit with the updated changelog change and force push your branch. The PR will get automatically updated.
68
69
 
69
- ```
70
+ ```bash
70
71
  git add CHANGELOG.md
71
72
  git commit --amend --no-edit
72
73
  git push origin fix-a-little-problem -f
@@ -80,14 +81,14 @@ A maintainer will review and probably merge you changes when time allows, be pat
80
81
 
81
82
  It's recommended that you keep your branch up-to-date by rebasing to the upstream main.
82
83
 
83
- ```
84
+ ```bash
84
85
  git fetch upstream
85
86
  git checkout fix-a-little-problem
86
87
  git rebase upstream/main
87
88
  git push origin fix-a-little-problem -f
88
89
  ```
89
90
 
90
- # Releasing a new version
91
+ ## Releasing a new version
91
92
 
92
93
  The version is using the [Semantic Versioning](http://semver.org/) and the version is located in the [version.rb](lib/jwt/version.rb) file.
93
94
  Also update the [CHANGELOG](CHANGELOG.md) to reflect the upcoming version release.
@@ -95,5 +96,3 @@ Also update the [CHANGELOG](CHANGELOG.md) to reflect the upcoming version releas
95
96
  ```bash
96
97
  rake release
97
98
  ```
98
-
99
- **If you want a release cut with your PR, please include a version bump according to **
data/README.md CHANGED
@@ -2,9 +2,8 @@
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/jwt.svg)](https://badge.fury.io/rb/jwt)
4
4
  [![Build Status](https://github.com/jwt/ruby-jwt/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/jwt/ruby-jwt/actions)
5
- [![Code Climate](https://codeclimate.com/github/jwt/ruby-jwt/badges/gpa.svg)](https://codeclimate.com/github/jwt/ruby-jwt)
6
- [![Test Coverage](https://codeclimate.com/github/jwt/ruby-jwt/badges/coverage.svg)](https://codeclimate.com/github/jwt/ruby-jwt/coverage)
7
- [![Issue Count](https://codeclimate.com/github/jwt/ruby-jwt/badges/issue_count.svg)](https://codeclimate.com/github/jwt/ruby-jwt)
5
+ [![Maintainability](https://qlty.sh/badges/6f61c5a6-6e23-41a7-8896-a3ce8b006655/maintainability.svg)](https://qlty.sh/gh/jwt/projects/ruby-jwt)
6
+ [![Code Coverage](https://qlty.sh/badges/6f61c5a6-6e23-41a7-8896-a3ce8b006655/test_coverage.svg)](https://qlty.sh/gh/jwt/projects/ruby-jwt)
8
7
 
9
8
  A ruby implementation of the [RFC 7519 OAuth JSON Web Token (JWT)](https://tools.ietf.org/html/rfc7519) standard.
10
9
 
@@ -18,28 +17,30 @@ Check out breaking changes in the upcoming **version 3.0** from the [upgrade gui
18
17
 
19
18
  ## Sponsors
20
19
 
21
- |Logo|Message|
22
- |-|-|
23
- |![auth0 logo](https://user-images.githubusercontent.com/83319/31722733-de95bbde-b3ea-11e7-96bf-4f4e8f915588.png)|If you want to quickly add secure token-based authentication to Ruby projects, feel free to check Auth0's Ruby SDK and free plan at [auth0.com/developers](https://auth0.com/developers?utm_source=GHsponsor&utm_medium=GHsponsor&utm_campaign=rubyjwt&utm_content=auth)|
20
+ | Logo | Message |
21
+ | ---------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
22
+ | ![auth0 logo](https://user-images.githubusercontent.com/83319/31722733-de95bbde-b3ea-11e7-96bf-4f4e8f915588.png) | If you want to quickly add secure token-based authentication to Ruby projects, feel free to check Auth0's Ruby SDK and free plan at [auth0.com/developers](https://auth0.com/developers?utm_source=GHsponsor&utm_medium=GHsponsor&utm_campaign=rubyjwt&utm_content=auth) |
24
23
 
25
24
  ## Installing
26
25
 
27
- ### Using Rubygems:
26
+ ### Using Rubygems
28
27
 
29
28
  ```bash
30
29
  gem install jwt
31
30
  ```
32
31
 
33
- ### Using Bundler:
32
+ ### Using Bundler
34
33
 
35
34
  Add the following to your Gemfile
36
- ```
35
+
36
+ ```bash
37
37
  gem 'jwt'
38
38
  ```
39
39
 
40
40
  And run `bundle install`
41
41
 
42
42
  Finally require the gem in your application
43
+
43
44
  ```ruby
44
45
  require 'jwt'
45
46
  ```
@@ -48,32 +49,15 @@ require 'jwt'
48
49
 
49
50
  The jwt gem natively supports the NONE, HMAC, RSASSA, ECDSA and RSASSA-PSS algorithms via the openssl library. The gem can be extended with additional or alternative implementations of the algorithms via extensions.
50
51
 
51
- Additionally the EdDSA algorithm is supported via a [separate gem](https://rubygems.org/gems/jwt-eddsa).
52
+ Additionally the EdDSA algorithm is supported via a the [jwt-eddsa gem](https://rubygems.org/gems/jwt-eddsa).
52
53
 
53
54
  For safe 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**
54
55
 
55
- See: [ JSON Web Algorithms (JWA) 3.1. "alg" (Algorithm) Header Parameter Values for JWS](https://tools.ietf.org/html/rfc7518#section-3.1)
56
-
57
- ### Deprecation warnings
58
-
59
- Deprecation warnings are logged once (`:once` option) by default to avoid spam in logs. Other options are `:silent` to completely silence warnings and `:warn` to log every time a deprecated path is executed.
60
-
61
- ```ruby
62
- JWT.configuration.deprecation_warnings = :warn # default is :once
63
- ```
64
-
65
- ### Base64 decoding
66
-
67
- In the past the gem has been supporting the Base64 decoding specified in [RFC2045](https://www.rfc-editor.org/rfc/rfc2045) allowing newlines and blanks in the base64 encoded payload. In future versions base64 decoding will be stricter and only comply to [RFC4648](https://www.rfc-editor.org/rfc/rfc4648).
68
-
69
- The stricter base64 decoding when processing tokens can be done via the `strict_base64_decoding` configuration accessor.
70
- ```ruby
71
- JWT.configuration.strict_base64_decoding = true # default is false
72
- ```
56
+ See [JSON Web Algorithms (JWA) 3.1. "alg" (Algorithm) Header Parameter Values for JWS](https://tools.ietf.org/html/rfc7518#section-3.1)
73
57
 
74
58
  ### **NONE**
75
59
 
76
- * none - unsigned token
60
+ - none - unsigned token
77
61
 
78
62
  ```ruby
79
63
 
@@ -98,9 +82,9 @@ puts decoded_token
98
82
 
99
83
  ### **HMAC**
100
84
 
101
- * HS256 - HMAC using SHA-256 hash algorithm
102
- * HS384 - HMAC using SHA-384 hash algorithm
103
- * HS512 - HMAC using SHA-512 hash algorithm
85
+ - HS256 - HMAC using SHA-256 hash algorithm
86
+ - HS384 - HMAC using SHA-384 hash algorithm
87
+ - HS512 - HMAC using SHA-512 hash algorithm
104
88
 
105
89
  ```ruby
106
90
  # The secret must be a string. With OpenSSL 3.0/openssl gem `<3.0.1`, JWT::DecodeError will be raised if it isn't provided.
@@ -123,9 +107,9 @@ puts decoded_token
123
107
 
124
108
  ### **RSA**
125
109
 
126
- * RS256 - RSA using SHA-256 hash algorithm
127
- * RS384 - RSA using SHA-384 hash algorithm
128
- * RS512 - RSA using SHA-512 hash algorithm
110
+ - RS256 - RSA using SHA-256 hash algorithm
111
+ - RS384 - RSA using SHA-384 hash algorithm
112
+ - RS512 - RSA using SHA-512 hash algorithm
129
113
 
130
114
  ```ruby
131
115
  rsa_private = OpenSSL::PKey::RSA.generate(2048)
@@ -148,10 +132,10 @@ puts decoded_token
148
132
 
149
133
  ### **ECDSA**
150
134
 
151
- * ES256 - ECDSA using P-256 and SHA-256
152
- * ES384 - ECDSA using P-384 and SHA-384
153
- * ES512 - ECDSA using P-521 and SHA-512
154
- * ES256K - ECDSA using P-256K and SHA-256
135
+ - ES256 - ECDSA using P-256 and SHA-256
136
+ - ES384 - ECDSA using P-384 and SHA-384
137
+ - ES512 - ECDSA using P-521 and SHA-512
138
+ - ES256K - ECDSA using P-256K and SHA-256
155
139
 
156
140
  ```ruby
157
141
  ecdsa_key = OpenSSL::PKey::EC.generate('prime256v1')
@@ -173,13 +157,13 @@ puts decoded_token
173
157
 
174
158
  ### **EdDSA**
175
159
 
176
- This algorithm has since version 3.0 been moved to the [jwt-eddsa](https://rubygems.org/gems/jwt-eddsa) gem.
160
+ This algorithm has since version 3.0 been moved to the [jwt-eddsa gem](https://rubygems.org/gems/jwt-eddsa).
177
161
 
178
162
  ### **RSASSA-PSS**
179
163
 
180
- * PS256 - RSASSA-PSS using SHA-256 hash algorithm
181
- * PS384 - RSASSA-PSS using SHA-384 hash algorithm
182
- * PS512 - RSASSA-PSS using SHA-512 hash algorithm
164
+ - PS256 - RSASSA-PSS using SHA-256 hash algorithm
165
+ - PS384 - RSASSA-PSS using SHA-384 hash algorithm
166
+ - PS512 - RSASSA-PSS using SHA-512 hash algorithm
183
167
 
184
168
  ```ruby
185
169
  rsa_private = OpenSSL::PKey::RSA.generate(2048)
@@ -200,37 +184,6 @@ decoded_token = JWT.decode(token, rsa_public, true, { algorithm: 'PS256' })
200
184
  puts decoded_token
201
185
  ```
202
186
 
203
- ### Add custom header fields
204
- Ruby-jwt gem supports custom [header fields](https://tools.ietf.org/html/rfc7519#section-5)
205
- To add custom header fields you need to pass `header_fields` parameter
206
-
207
- ```ruby
208
- token = JWT.encode(payload, key, 'HS256', header_fields={})
209
- ```
210
-
211
- **Example:**
212
-
213
- ```ruby
214
-
215
- payload = { data: 'test' }
216
-
217
- # IMPORTANT: set nil as password parameter
218
- token = JWT.encode(payload, nil, 'none', { typ: 'JWT' })
219
-
220
- # eyJhbGciOiJub25lIiwidHlwIjoiSldUIn0.eyJkYXRhIjoidGVzdCJ9.
221
- puts token
222
-
223
- # Set password to nil and validation to false otherwise this won't work
224
- decoded_token = JWT.decode(token, nil, false)
225
-
226
- # Array
227
- # [
228
- # {"data"=>"test"}, # payload
229
- # {"typ"=>"JWT", "alg"=>"none"} # header
230
- # ]
231
- puts decoded_token
232
- ```
233
-
234
187
  ### **Custom algorithms**
235
188
 
236
189
  When encoding or decoding a token, you can pass in a custom object through the `algorithm` option to handle signing or verification. This custom object must include or extend the `JWT::JWA::SigningAlgorithm` module and implement certain methods:
@@ -240,7 +193,6 @@ When encoding or decoding a token, you can pass in a custom object through the `
240
193
 
241
194
  For customization options check the details from `JWT::JWA::SigningAlgorithm`.
242
195
 
243
-
244
196
  ```ruby
245
197
  module CustomHS512Algorithm
246
198
  extend JWT::JWA::SigningAlgorithm
@@ -262,10 +214,44 @@ token = ::JWT.encode({'pay' => 'load'}, 'secret', CustomHS512Algorithm)
262
214
  payload, header = ::JWT.decode(token, 'secret', true, algorithm: CustomHS512Algorithm)
263
215
  ```
264
216
 
217
+ ### Add custom header fields
218
+
219
+ The ruby-jwt gem supports custom [header fields](https://tools.ietf.org/html/rfc7519#section-5)
220
+ To add custom header fields you need to pass `header_fields` parameter
221
+
222
+ ```ruby
223
+ token = JWT.encode(payload, key, 'HS256', {})
224
+ ```
225
+
226
+ **Example:**
227
+
228
+ ```ruby
229
+
230
+ payload = { data: 'test' }
231
+
232
+ # IMPORTANT: set nil as password parameter
233
+ token = JWT.encode(payload, nil, 'none', { typ: 'JWT' })
234
+
235
+ # eyJhbGciOiJub25lIiwidHlwIjoiSldUIn0.eyJkYXRhIjoidGVzdCJ9.
236
+ puts token
237
+
238
+ # Set password to nil and validation to false otherwise this won't work
239
+ decoded_token = JWT.decode(token, nil, false)
240
+
241
+ # Array
242
+ # [
243
+ # {"data"=>"test"}, # payload
244
+ # {"typ"=>"JWT", "alg"=>"none"} # header
245
+ # ]
246
+ puts decoded_token
247
+ ```
248
+
265
249
  ## `JWT::Token` and `JWT::EncodedToken`
266
250
 
267
251
  The `JWT::Token` and `JWT::EncodedToken` classes can be used to manage your JWTs.
268
252
 
253
+ ### Signing and encoding a token
254
+
269
255
  ```ruby
270
256
  token = JWT::Token.new(payload: { exp: Time.now.to_i + 60, jti: '1234', sub: "my-subject" }, header: { kid: 'hmac' })
271
257
  token.sign!(algorithm: 'HS256', key: "secret")
@@ -273,7 +259,10 @@ token.sign!(algorithm: 'HS256', key: "secret")
273
259
  token.jwt # => "eyJhbGciOiJIUzI1N..."
274
260
  ```
275
261
 
276
- The `JWT::EncodedToken` can be used to create a token object that allows verification of signatures and claims
262
+ ### Verifying and decoding a token
263
+
264
+ The `JWT::EncodedToken` can be used as a token object that allows verification of signatures and claims.
265
+
277
266
  ```ruby
278
267
  encoded_token = JWT::EncodedToken.new(token.jwt)
279
268
 
@@ -291,14 +280,16 @@ The `JWT::EncodedToken#verify!` method can be used to verify signature and claim
291
280
  ```ruby
292
281
  encoded_token = JWT::EncodedToken.new(token.jwt)
293
282
  encoded_token.verify!(signature: {algorithm: 'HS256', key: "secret"})
294
-
295
283
  encoded_token.payload # => { 'exp'=>1234, 'jti'=>'1234", 'sub'=>'my-subject' }
296
284
  encoded_token.header # {'kid'=>'hmac', 'alg'=>'HS256'}
297
285
  ```
298
286
 
287
+ #### Keyfinders
288
+
299
289
  A keyfinder can be used to verify a signature. A keyfinder is an object responding to the `#call` method. The method expects to receive one argument, which is the token to be verified.
300
290
 
301
- An example on using the built-in JWK keyfinder:
291
+ An example on using the built-in JWK keyfinder.
292
+
302
293
  ```ruby
303
294
  # Create and sign a token
304
295
  jwk = JWT::JWK.new(OpenSSL::PKey::RSA.generate(2048))
@@ -312,7 +303,8 @@ encoded_token.verify!(signature: { algorithm: 'RS256', key_finder: key_finder})
312
303
  encoded_token.payload # => { 'pay' => 'load' }
313
304
  ```
314
305
 
315
- Using a custom keyfinder proc:
306
+ Using a custom keyfinder proc.
307
+
316
308
  ```ruby
317
309
  # Create and sign a token
318
310
  key = OpenSSL::PKey::RSA.generate(2048)
@@ -351,21 +343,19 @@ encoded_token.payload # => {"pay"=>"load"}
351
343
  JSON Web Token defines some reserved claim names and defines how they should be
352
344
  used. JWT supports these reserved claim names:
353
345
 
354
- - 'exp' (Expiration Time) Claim
355
- - 'nbf' (Not Before Time) Claim
356
- - 'iss' (Issuer) Claim
357
- - 'aud' (Audience) Claim
358
- - 'jti' (JWT ID) Claim
359
- - 'iat' (Issued At) Claim
360
- - 'sub' (Subject) Claim
346
+ - 'exp' (Expiration Time) Claim
347
+ - 'nbf' (Not Before Time) Claim
348
+ - 'iss' (Issuer) Claim
349
+ - 'aud' (Audience) Claim
350
+ - 'jti' (JWT ID) Claim
351
+ - 'iat' (Issued At) Claim
352
+ - 'sub' (Subject) Claim
361
353
 
362
354
  ### Expiration Time Claim
363
355
 
364
356
  From [Oauth JSON Web Token 4.1.4. "exp" (Expiration Time) Claim](https://tools.ietf.org/html/rfc7519#section-4.1.4):
365
357
 
366
- > The `exp` (expiration time) claim identifies the expiration time on or after which the JWT MUST NOT be accepted for processing. The processing of the `exp` claim requires that the current date/time MUST be before the expiration date/time listed in the `exp` claim. Implementers MAY provide for some small `leeway`, usually no more than a few minutes, to account for clock skew. Its value MUST be a number containing a ***NumericDate*** value. Use of this claim is OPTIONAL.
367
-
368
- **Handle Expiration Claim**
358
+ > The `exp` (expiration time) claim identifies the expiration time on or after which the JWT MUST NOT be accepted for processing. The processing of the `exp` claim requires that the current date/time MUST be before the expiration date/time listed in the `exp` claim. Implementers MAY provide for some small `leeway`, usually no more than a few minutes, to account for clock skew. Its value MUST be a number containing a **_NumericDate_** value. Use of this claim is OPTIONAL.
369
359
 
370
360
  ```ruby
371
361
  exp = Time.now.to_i + 4 * 3600
@@ -381,12 +371,13 @@ end
381
371
  ```
382
372
 
383
373
  The Expiration Claim verification can be disabled.
374
+
384
375
  ```ruby
385
376
  # Decode token without raising JWT::ExpiredSignature error
386
377
  JWT.decode(token, hmac_secret, true, { verify_expiration: false, algorithm: 'HS256' })
387
378
  ```
388
379
 
389
- **Adding Leeway**
380
+ Leeway and the exp claim.
390
381
 
391
382
  ```ruby
392
383
  exp = Time.now.to_i - 10
@@ -409,9 +400,7 @@ end
409
400
 
410
401
  From [Oauth JSON Web Token 4.1.5. "nbf" (Not Before) Claim](https://tools.ietf.org/html/rfc7519#section-4.1.5):
411
402
 
412
- > The `nbf` (not before) claim identifies the time before which the JWT MUST NOT be accepted for processing. The processing of the `nbf` claim requires that the current date/time MUST be after or equal to the not-before date/time listed in the `nbf` claim. Implementers MAY provide for some small `leeway`, usually no more than a few minutes, to account for clock skew. Its value MUST be a number containing a ***NumericDate*** value. Use of this claim is OPTIONAL.
413
-
414
- **Handle Not Before Claim**
403
+ > The `nbf` (not before) claim identifies the time before which the JWT MUST NOT be accepted for processing. The processing of the `nbf` claim requires that the current date/time MUST be after or equal to the not-before date/time listed in the `nbf` claim. Implementers MAY provide for some small `leeway`, usually no more than a few minutes, to account for clock skew. Its value MUST be a number containing a **_NumericDate_** value. Use of this claim is OPTIONAL.
415
404
 
416
405
  ```ruby
417
406
  nbf = Time.now.to_i - 3600
@@ -427,12 +416,13 @@ end
427
416
  ```
428
417
 
429
418
  The Not Before Claim verification can be disabled.
419
+
430
420
  ```ruby
431
421
  # Decode token without raising JWT::ImmatureSignature error
432
422
  JWT.decode(token, hmac_secret, true, { verify_not_before: false, algorithm: 'HS256' })
433
423
  ```
434
424
 
435
- **Adding Leeway**
425
+ Leeway and the nbf claim.
436
426
 
437
427
  ```ruby
438
428
  nbf = Time.now.to_i + 10
@@ -455,7 +445,7 @@ end
455
445
 
456
446
  From [Oauth JSON Web Token 4.1.1. "iss" (Issuer) Claim](https://tools.ietf.org/html/rfc7519#section-4.1.1):
457
447
 
458
- > The `iss` (issuer) claim identifies the principal that issued the JWT. The processing of this claim is generally application specific. The `iss` value is a case-sensitive string containing a ***StringOrURI*** value. Use of this claim is OPTIONAL.
448
+ > The `iss` (issuer) claim identifies the principal that issued the JWT. The processing of this claim is generally application specific. The `iss` value is a case-sensitive string containing a **_StringOrURI_** value. Use of this claim is OPTIONAL.
459
449
 
460
450
  You can pass multiple allowed issuers as an Array, verification will pass if one of them matches the `iss` value in the payload.
461
451
 
@@ -507,7 +497,7 @@ end
507
497
 
508
498
  From [Oauth JSON Web Token 4.1.3. "aud" (Audience) Claim](https://tools.ietf.org/html/rfc7519#section-4.1.3):
509
499
 
510
- > The `aud` (audience) claim identifies the recipients that the JWT is intended for. Each principal intended to process the JWT MUST identify itself with a value in the audience claim. If the principal processing the claim does not identify itself with a value in the `aud` claim when this claim is present, then the JWT MUST be rejected. In the general case, the `aud` value is an array of case-sensitive strings, each containing a ***StringOrURI*** value. In the special case when the JWT has one audience, the `aud` value MAY be a single case-sensitive string containing a ***StringOrURI*** value. The interpretation of audience values is generally application specific. Use of this claim is OPTIONAL.
500
+ > The `aud` (audience) claim identifies the recipients that the JWT is intended for. Each principal intended to process the JWT MUST identify itself with a value in the audience claim. If the principal processing the claim does not identify itself with a value in the `aud` claim when this claim is present, then the JWT MUST be rejected. In the general case, the `aud` value is an array of case-sensitive strings, each containing a **_StringOrURI_** value. In the special case when the JWT has one audience, the `aud` value MAY be a single case-sensitive string containing a **_StringOrURI_** value. The interpretation of audience values is generally application specific. Use of this claim is OPTIONAL.
511
501
 
512
502
  ```ruby
513
503
  aud = ['Young', 'Old']
@@ -555,9 +545,7 @@ end
555
545
 
556
546
  From [Oauth JSON Web Token 4.1.6. "iat" (Issued At) Claim](https://tools.ietf.org/html/rfc7519#section-4.1.6):
557
547
 
558
- > The `iat` (issued at) claim identifies the time at which the JWT was issued. This claim can be used to determine the age of the JWT. The `leeway` option is not taken into account when verifying this claim. The `iat_leeway` option was removed in version 2.2.0. Its value MUST be a number containing a ***NumericDate*** value. Use of this claim is OPTIONAL.
559
-
560
- **Handle Issued At Claim**
548
+ > The `iat` (issued at) claim identifies the time at which the JWT was issued. This claim can be used to determine the age of the JWT. The `leeway` option is not taken into account when verifying this claim. The `iat_leeway` option was removed in version 2.2.0. Its value MUST be a number containing a **_NumericDate_** value. Use of this claim is OPTIONAL.
561
549
 
562
550
  ```ruby
563
551
  iat = Time.now.to_i
@@ -577,7 +565,7 @@ end
577
565
 
578
566
  From [Oauth JSON Web Token 4.1.2. "sub" (Subject) Claim](https://tools.ietf.org/html/rfc7519#section-4.1.2):
579
567
 
580
- > The `sub` (subject) claim identifies the principal that is the subject of the JWT. The Claims in a JWT are normally statements about the subject. The subject value MUST either be scoped to be locally unique in the context of the issuer or be globally unique. The processing of this claim is generally application specific. The sub value is a case-sensitive string containing a ***StringOrURI*** value. Use of this claim is OPTIONAL.
568
+ > The `sub` (subject) claim identifies the principal that is the subject of the JWT. The Claims in a JWT are normally statements about the subject. The subject value MUST either be scoped to be locally unique in the context of the issuer or be globally unique. The processing of this claim is generally application specific. The sub value is a case-sensitive string containing a **_StringOrURI_** value. Use of this claim is OPTIONAL.
581
569
 
582
570
  ```ruby
583
571
  sub = 'Subject'
@@ -598,6 +586,7 @@ end
598
586
  The JWT claim verifications can be used to verify any Hash to include expected keys and values.
599
587
 
600
588
  A few example on verifying the claims for a payload:
589
+
601
590
  ```ruby
602
591
  JWT::Claims.verify_payload!({"exp" => Time.now.to_i + 10}, :numeric, :exp)
603
592
  JWT::Claims.valid_payload?({"exp" => Time.now.to_i + 10}, :exp)
@@ -634,6 +623,7 @@ end
634
623
  ### Required Claims
635
624
 
636
625
  You can specify claims that must be present for decoding to be successful. JWT::MissingRequiredClaim will be raised if any are missing
626
+
637
627
  ```ruby
638
628
  # Will raise a JWT::MissingRequiredClaim error if the 'exp' claim is absent
639
629
  JWT.decode(token, hmac_secret, true, { required_claims: ['exp'], algorithm: 'HS256' })
@@ -772,7 +762,7 @@ jwk_hash = jwk.export
772
762
  thumbprint_as_the_kid = jwk_hash[:kid]
773
763
  ```
774
764
 
775
- # Development and testing
765
+ ## Development and testing
776
766
 
777
767
  The tests are written with rspec. [Appraisal](https://github.com/thoughtbot/appraisal) is used to ensure compatibility with 3rd party dependencies providing cryptographic features.
778
768
 
@@ -781,7 +771,7 @@ bundle install
781
771
  bundle exec appraisal rake test
782
772
  ```
783
773
 
784
- # Releasing
774
+ ## Releasing
785
775
 
786
776
  To cut a new release adjust the [version.rb](lib/jwt/version.rb) and [CHANGELOG](CHANGELOG.md) with desired version numbers and dates and commit the changes. Tag the release with the version number using the following command:
787
777
 
@@ -792,6 +782,7 @@ rake release:source_control_push
792
782
  This will tag a new version an trigger a [GitHub action](.github/workflows/push_gem.yml) that eventually will push the gem to rubygems.org.
793
783
 
794
784
  ## How to contribute
785
+
795
786
  See [CONTRIBUTING](CONTRIBUTING.md).
796
787
 
797
788
  ## Contributors
data/UPGRADING.md CHANGED
@@ -38,6 +38,7 @@ Claim verification has been [split into separate classes](https://github.com/jwt
38
38
  ## Algorithm restructuring
39
39
 
40
40
  The internal algorithms were [restructured](https://github.com/jwt/ruby-jwt/pull/607) to support extensions from separate libraries. The changes led to a few deprecations and new requirements:
41
+
41
42
  - The `sign` and `verify` static methods on all the algorithms (`::JWT::JWA`) will be removed.
42
43
  - Custom algorithms are expected to include the `JWT::JWA::SigningAlgorithm` module.
43
44
 
data/lib/jwt/decode.rb CHANGED
@@ -6,6 +6,11 @@ require 'jwt/x5c_key_finder'
6
6
  module JWT
7
7
  # The Decode class is responsible for decoding and verifying JWT tokens.
8
8
  class Decode
9
+ # Order is very important - first check for string keys, next for symbols
10
+ ALGORITHM_KEYS = ['algorithm',
11
+ :algorithm,
12
+ 'algorithms',
13
+ :algorithms].freeze
9
14
  # Initializes a new Decode instance.
10
15
  #
11
16
  # @param jwt [String] the JWT to decode.
@@ -70,12 +75,6 @@ module JWT
70
75
  @allowed_and_valid_algorithms ||= allowed_algorithms.select { |alg| alg.valid_alg?(alg_in_header) }
71
76
  end
72
77
 
73
- # Order is very important - first check for string keys, next for symbols
74
- ALGORITHM_KEYS = ['algorithm',
75
- :algorithm,
76
- 'algorithms',
77
- :algorithms].freeze
78
-
79
78
  def given_algorithms
80
79
  alg_key = ALGORITHM_KEYS.find { |key| @options[key] }
81
80
  Array(@options[alg_key])
data/lib/jwt/error.rb CHANGED
@@ -7,9 +7,6 @@ module JWT
7
7
  # The DecodeError class is raised when there is an error decoding a JWT.
8
8
  class DecodeError < StandardError; end
9
9
 
10
- # The RequiredDependencyError class is raised when a required dependency is missing.
11
- class RequiredDependencyError < StandardError; end
12
-
13
10
  # The VerificationError class is raised when there is an error verifying a JWT.
14
11
  class VerificationError < DecodeError; end
15
12
 
data/lib/jwt/jwk/ec.rb CHANGED
@@ -68,7 +68,7 @@ module JWT
68
68
  def []=(key, value)
69
69
  raise ArgumentError, 'cannot overwrite cryptographic key attributes' if EC_KEY_ELEMENTS.include?(key.to_sym)
70
70
 
71
- super(key, value)
71
+ super
72
72
  end
73
73
 
74
74
  private
data/lib/jwt/jwk/hmac.rb CHANGED
@@ -64,7 +64,7 @@ module JWT
64
64
  def []=(key, value)
65
65
  raise ArgumentError, 'cannot overwrite cryptographic key attributes' if HMAC_KEY_ELEMENTS.include?(key.to_sym)
66
66
 
67
- super(key, value)
67
+ super
68
68
  end
69
69
 
70
70
  private
data/lib/jwt/jwk/rsa.rb CHANGED
@@ -67,7 +67,7 @@ module JWT
67
67
  def []=(key, value)
68
68
  raise ArgumentError, 'cannot overwrite cryptographic key attributes' if RSA_KEY_ELEMENTS.include?(key.to_sym)
69
69
 
70
- super(key, value)
70
+ super
71
71
  end
72
72
 
73
73
  private
data/lib/jwt/version.rb CHANGED
@@ -17,7 +17,7 @@ module JWT
17
17
  MAJOR = 3
18
18
  MINOR = 0
19
19
  TINY = 0
20
- PRE = 'beta1'
20
+ PRE = nil
21
21
 
22
22
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
23
23
  end
data/ruby-jwt.gemspec CHANGED
@@ -35,6 +35,7 @@ Gem::Specification.new do |spec|
35
35
 
36
36
  spec.add_development_dependency 'appraisal'
37
37
  spec.add_development_dependency 'bundler'
38
+ spec.add_development_dependency 'logger'
38
39
  spec.add_development_dependency 'rake'
39
40
  spec.add_development_dependency 'rspec'
40
41
  spec.add_development_dependency 'rubocop'
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jwt
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.beta1
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Rudat
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-01-25 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: base64
@@ -51,6 +51,20 @@ dependencies:
51
51
  - - ">="
52
52
  - !ruby/object:Gem::Version
53
53
  version: '0'
54
+ - !ruby/object:Gem::Dependency
55
+ name: logger
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ type: :development
62
+ prerelease: false
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
54
68
  - !ruby/object:Gem::Dependency
55
69
  name: rake
56
70
  requirement: !ruby/object:Gem::Requirement
@@ -171,7 +185,7 @@ licenses:
171
185
  - MIT
172
186
  metadata:
173
187
  bug_tracker_uri: https://github.com/jwt/ruby-jwt/issues
174
- changelog_uri: https://github.com/jwt/ruby-jwt/blob/v3.0.0.beta1/CHANGELOG.md
188
+ changelog_uri: https://github.com/jwt/ruby-jwt/blob/v3.0.0/CHANGELOG.md
175
189
  rubygems_mfa_required: 'true'
176
190
  rdoc_options: []
177
191
  require_paths:
@@ -187,7 +201,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
187
201
  - !ruby/object:Gem::Version
188
202
  version: '0'
189
203
  requirements: []
190
- rubygems_version: 3.6.2
204
+ rubygems_version: 3.6.7
191
205
  specification_version: 4
192
206
  summary: JSON Web Token implementation in Ruby
193
207
  test_files: []