Skip to content

Commit 1ee202e

Browse files
committed
List of deprecations
1 parent 8cc1fce commit 1ee202e

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

CHANGELOG.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,27 @@
11
# Changelog
22

3+
## Upcoming breaking changes
4+
5+
Notable changes in the upcoming **version 3.0**:
6+
7+
- The indirect dependency to [rbnacl](https://github.com/RubyCrypto/rbnacl) will be removed:
8+
- Support for the nonstandard SHA512256 algorithm will be removed.
9+
- Support for Ed25519 will be moved to a [separate gem](https://github.com/anakinj/jwt-eddsa) for better dependency handling.
10+
11+
- Base64 decoding will no longer fallback on the looser RFC 2045.
12+
13+
- Claim verification has been [split into separate classes](https://github.com/jwt/ruby-jwt/pull/605) and has [a new api](https://github.com/jwt/ruby-jwt/pull/626) and lead to the following deprecations:
14+
- The `::JWT::ClaimsValidator` class will be removed in favor of the functionality provided by `::JWT::Claims`.
15+
- The `::JWT::Claims::verify!` method will be removed in favor of `::JWT::Claims::verify_payload!`.
16+
- The `::JWT::JWA.create` method will be removed. No recommended alternatives.
17+
- The `::JWT::Verify` class will be removed in favor of the functionality provided by `::JWT::Claims`.
18+
- Calling `::JWT::Claims::Numeric.new` with a payload will be removed in favor of `::JWT::Claims::verify_payload!(payload, :numeric)`
19+
- Calling `::JWT::Claims::Numeric.verify!` with a payload will be removed in favor of `::JWT::Claims::verify_payload!(payload, :numeric)`
20+
21+
- The internal algorithms were [restructured](https://github.com/jwt/ruby-jwt/pull/607) to support extensions from separate libraries. The changes lead to a few deprecations and new requirements:
22+
- The `sign` and `verify` static methods on all the algorithms (`::JWT::JWA`) will be removed.
23+
- Custom algorithms are expected to include the `JWT::JWA::SigningAlgorithm` module.
24+
325
## [v2.9.2](https://github.com/jwt/ruby-jwt/tree/v2.9.2) (NEXT)
426

527
[Full Changelog](https://github.com/jwt/ruby-jwt/compare/v2.9.1...main)

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,24 @@ rescue JWT::InvalidSubError
530530
end
531531
```
532532

533+
### Standalone claim verification
534+
535+
The JWT claim verifications can be used to verify any Hash to include expected keys and values.
536+
537+
A few example on verifying the claims for a payload:
538+
```ruby
539+
JWT::Claims.verify_payload!({"exp" => Time.now.to_i + 10}, :numeric, :exp)
540+
JWT::Claims.valid_payload?({"exp" => Time.now.to_i + 10}, :exp)
541+
# => true
542+
JWT::Claims.payload_errors({"exp" => Time.now.to_i - 10}, :exp)
543+
# => [#<struct JWT::Claims::Error message="Signature has expired">]
544+
JWT::Claims.verify_payload!({"exp" => Time.now.to_i - 10}, exp: { leeway: 11})
545+
546+
JWT::Claims.verify_payload!({"exp" => Time.now.to_i + 10, "sub" => "subject"}, :exp, sub: "subject")
547+
```
548+
549+
550+
533551
### Finding a Key
534552

535553
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.

0 commit comments

Comments
 (0)