Class: Warden::Auth0::TokenDecoder
- Inherits:
-
Object
- Object
- Warden::Auth0::TokenDecoder
- Defined in:
- lib/warden/auth0/token_decoder.rb
Overview
Decodes a JWT into a hash payload. Algorithm and JWKS are provided by the strategy config.
Instance Attribute Summary collapse
-
#algorithm ⇒ Object
readonly
Returns the value of attribute algorithm.
-
#jwks ⇒ Object
readonly
Returns the value of attribute jwks.
Instance Method Summary collapse
-
#call(token) ⇒ Hash
Decodes the payload from a JWT as a hash.
-
#initialize(algorithm:, jwks:) ⇒ TokenDecoder
constructor
A new instance of TokenDecoder.
Constructor Details
#initialize(algorithm:, jwks:) ⇒ TokenDecoder
Returns a new instance of TokenDecoder.
13 14 15 16 |
# File 'lib/warden/auth0/token_decoder.rb', line 13 def initialize(algorithm:, jwks:) @algorithm = algorithm @jwks = jwks end |
Instance Attribute Details
#algorithm ⇒ Object (readonly)
Returns the value of attribute algorithm.
9 10 11 |
# File 'lib/warden/auth0/token_decoder.rb', line 9 def algorithm @algorithm end |
#jwks ⇒ Object (readonly)
Returns the value of attribute jwks.
9 10 11 |
# File 'lib/warden/auth0/token_decoder.rb', line 9 def jwks @jwks end |
Instance Method Details
#call(token) ⇒ Hash
Decodes the payload from a JWT as a hash
22 23 24 |
# File 'lib/warden/auth0/token_decoder.rb', line 22 def call(token) JWT.decode(token, nil, true, algorithms: algorithm, jwks: jwks)[0] end |