Class: Warden::JWTAuth::UserEncoder
- Inherits:
-
Object
- Object
- Warden::JWTAuth::UserEncoder
- Defined in:
- lib/warden/jwt_auth/user_encoder.rb
Overview
Layer above token encoding which directly encodes a user to a JWT
Instance Attribute Summary collapse
-
#helper ⇒ Object
readonly
Returns the value of attribute helper.
Instance Method Summary collapse
-
#call(user, scope) ⇒ String
Encodes a user for given scope into a JWT.
-
#initialize ⇒ UserEncoder
constructor
A new instance of UserEncoder.
Constructor Details
#initialize ⇒ UserEncoder
Returns a new instance of UserEncoder.
11 12 13 |
# File 'lib/warden/jwt_auth/user_encoder.rb', line 11 def initialize @helper = PayloadUserHelper end |
Instance Attribute Details
#helper ⇒ Object (readonly)
Returns the value of attribute helper.
9 10 11 |
# File 'lib/warden/jwt_auth/user_encoder.rb', line 9 def helper @helper end |
Instance Method Details
#call(user, scope) ⇒ String
Encodes a user for given scope into a JWT. Payload generated includes a ‘sub` claim which is build calling `jwt_subject` in `user`, and a custom `scp` claim which value is `scope` as a string. The result of calling `jwt_payload` in user is also merged into the payload.
23 24 25 26 |
# File 'lib/warden/jwt_auth/user_encoder.rb', line 23 def call(user, scope) payload = helper.payload_for_user(user, scope) TokenEncoder.new.call(payload) end |