Class: JWT::Decode
- Inherits:
-
Object
- Object
- JWT::Decode
- Defined in:
- lib/jwt/decode.rb
Overview
Decoding logic for JWT
Instance Method Summary collapse
- #decode_segments ⇒ Object
-
#initialize(jwt, key, verify, options, &keyfinder) ⇒ Decode
constructor
A new instance of Decode.
Constructor Details
#initialize(jwt, key, verify, options, &keyfinder) ⇒ Decode
Returns a new instance of Decode.
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/jwt/decode.rb', line 10 def initialize(jwt, key, verify, , &keyfinder) raise JWT::DecodeError, 'Nil JSON web token' unless jwt @jwt = jwt @key = key @options = @segments = jwt.split('.') @verify = verify @signature = '' @keyfinder = keyfinder end |
Instance Method Details
#decode_segments ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/jwt/decode.rb', line 22 def decode_segments validate_segment_count! if @verify decode_signature verify_algo set_key verify_signature verify_claims end raise JWT::DecodeError, 'Not enough or too many segments' unless header && payload [payload, header] end |