Class: Warden::JWTAuth::UserDecoder
- Inherits:
-
Object
- Object
- Warden::JWTAuth::UserDecoder
- Defined in:
- lib/warden/jwt_auth/user_decoder.rb
Overview
Layer above token decoding which directly decodes a user from a JWT
Instance Attribute Summary collapse
-
#helper ⇒ Object
readonly
Returns the value of attribute helper.
Instance Method Summary collapse
-
#call(token, scope, aud) ⇒ Interfaces::User
Returns the user that is encoded in a JWT.
-
#initialize(**args) ⇒ UserDecoder
constructor
A new instance of UserDecoder.
Constructor Details
#initialize(**args) ⇒ UserDecoder
Returns a new instance of UserDecoder.
13 14 15 16 |
# File 'lib/warden/jwt_auth/user_decoder.rb', line 13 def initialize(**args) super @helper = PayloadUserHelper end |
Instance Attribute Details
#helper ⇒ Object (readonly)
Returns the value of attribute helper.
11 12 13 |
# File 'lib/warden/jwt_auth/user_decoder.rb', line 11 def helper @helper end |
Instance Method Details
#call(token, scope, aud) ⇒ Interfaces::User
Returns the user that is encoded in a JWT. The scope is used to choose the user repository to which send ‘#find_for_jwt_authentication(sub)` with decoded `sub` claim.
encoded user argument
32 33 34 35 36 37 38 |
# File 'lib/warden/jwt_auth/user_decoder.rb', line 32 def call(token, scope, aud) payload = TokenDecoder.new.call(token) check_valid_claims(payload, scope, aud) user = helper.find_user(payload) check_valid_user(payload, user, scope) user end |