Class: JSONWebToken::HMACToken
- Defined in:
- lib/json_web_token/hmac_token.rb
Direct Known Subclasses
Constant Summary collapse
- LEEWAY =
60
- JWT_ALGORITHM =
'HS256'
Constants inherited from Token
Token::DEFAULT_EXPIRE_TIME, Token::DEFAULT_NOT_BEFORE_TIME
Instance Attribute Summary
Attributes inherited from Token
#audience, #expire_time, #id, #issued_at, #issuer, #not_before, #subject
Class Method Summary collapse
Instance Method Summary collapse
- #encoded ⇒ Object
-
#initialize(secret) ⇒ HMACToken
constructor
A new instance of HMACToken.
Methods inherited from Token
Constructor Details
#initialize(secret) ⇒ HMACToken
Returns a new instance of HMACToken.
10 11 12 13 14 |
# File 'lib/json_web_token/hmac_token.rb', line 10 def initialize(secret) super() @secret = secret end |
Class Method Details
.decode(token, secret, leeway: LEEWAY, verify_iat: false) ⇒ Object
16 17 18 |
# File 'lib/json_web_token/hmac_token.rb', line 16 def self.decode(token, secret, leeway: LEEWAY, verify_iat: false) JWT.decode(token, secret, true, leeway: leeway, verify_iat: verify_iat, algorithm: JWT_ALGORITHM) end |
Instance Method Details
#encoded ⇒ Object
20 21 22 |
# File 'lib/json_web_token/hmac_token.rb', line 20 def encoded JWT.encode(payload, secret, JWT_ALGORITHM, { typ: 'JWT' }) end |