Class: SimpleJwtAuth::Encode
- Inherits:
-
Object
- Object
- SimpleJwtAuth::Encode
- Includes:
- Traits::Configurable
- Defined in:
- lib/simple_jwt_auth/encode.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(payload: {}, claims: {}, header_fields: {}) ⇒ Encode
constructor
A new instance of Encode.
Constructor Details
#initialize(payload: {}, claims: {}, header_fields: {}) ⇒ Encode
Returns a new instance of Encode.
7 8 9 10 11 |
# File 'lib/simple_jwt_auth/encode.rb', line 7 def initialize(payload: {}, claims: {}, header_fields: {}) @payload = payload @claims = claims @header_fields = header_fields end |
Instance Method Details
#call ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/simple_jwt_auth/encode.rb', line 13 def call jwt_payload = payload.merge(claims) issuer = jwt_payload.fetch(:iss) config.logger.debug "Encoding JWT payload: #{jwt_payload}" JWT.encode( jwt_payload, secrets.secret_for(issuer), config.algorithm, header_fields ) end |