Class: JWT::Decode
- Inherits:
-
Object
- Object
- JWT::Decode
- Defined in:
- lib/jwt/decode.rb
Overview
The Decode class is responsible for decoding and verifying JWT tokens.
Instance Method Summary collapse
-
#decode_segments ⇒ Array<Hash>
Decodes the JWT token and verifies its segments if verification is enabled.
-
#initialize(jwt, key, verify, options, &keyfinder) ⇒ Decode
constructor
Initializes a new Decode instance.
Constructor Details
#initialize(jwt, key, verify, options, &keyfinder) ⇒ Decode
Initializes a new Decode instance.
17 18 19 20 21 22 23 24 25 |
# File 'lib/jwt/decode.rb', line 17 def initialize(jwt, key, verify, , &keyfinder) raise JWT::DecodeError, 'Nil JSON web token' unless jwt @token = EncodedToken.new(jwt) @key = key @options = @verify = verify @keyfinder = keyfinder end |
Instance Method Details
#decode_segments ⇒ Array<Hash>
Decodes the JWT token and verifies its segments if verification is enabled.
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/jwt/decode.rb', line 30 def decode_segments validate_segment_count! if @verify verify_algo set_key verify_signature Claims::DecodeVerifier.verify!(token.payload, @options) end [token.payload, token.header] end |