Class: Reattract::JwtGenerator
- Inherits:
-
Object
- Object
- Reattract::JwtGenerator
- Defined in:
- lib/reattract/jwt_generator.rb
Overview
Handles generation of JWTs
Constant Summary collapse
- ALGO_HMAC_256 =
'HS256'
Instance Attribute Summary collapse
-
#expired_at ⇒ Object
Returns the value of attribute expired_at.
-
#scopes ⇒ Object
Returns the value of attribute scopes.
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(expired_at: default_exp, scopes: nil) ⇒ JwtGenerator
constructor
A new instance of JwtGenerator.
Constructor Details
#initialize(expired_at: default_exp, scopes: nil) ⇒ JwtGenerator
Returns a new instance of JwtGenerator.
12 13 14 15 |
# File 'lib/reattract/jwt_generator.rb', line 12 def initialize(expired_at: default_exp, scopes: nil) @expired_at = expired_at.to_i @scopes = scopes&.join(',') end |
Instance Attribute Details
#expired_at ⇒ Object
Returns the value of attribute expired_at.
10 11 12 |
# File 'lib/reattract/jwt_generator.rb', line 10 def expired_at @expired_at end |
#scopes ⇒ Object
Returns the value of attribute scopes.
10 11 12 |
# File 'lib/reattract/jwt_generator.rb', line 10 def scopes @scopes end |
Instance Method Details
#generate ⇒ Object
17 18 19 |
# File 'lib/reattract/jwt_generator.rb', line 17 def generate JWT.encode payload, hmac_secret, algorithm end |