Class: MaticJWT::Authenticator
- Inherits:
-
Object
- Object
- MaticJWT::Authenticator
- Defined in:
- lib/matic-jwt/authenticator.rb
Constant Summary collapse
- TOKEN_TYPE =
'Bearer: '.freeze
Instance Method Summary collapse
- #authenticate_with_secret!(secret) ⇒ Object
- #client_name ⇒ Object
-
#initialize(headers) ⇒ Authenticator
constructor
A new instance of Authenticator.
Constructor Details
#initialize(headers) ⇒ Authenticator
Returns a new instance of Authenticator.
5 6 7 |
# File 'lib/matic-jwt/authenticator.rb', line 5 def initialize(headers) @token = extract_token(headers) end |
Instance Method Details
#authenticate_with_secret!(secret) ⇒ Object
13 14 15 |
# File 'lib/matic-jwt/authenticator.rb', line 13 def authenticate_with_secret!(secret) JWT.decode(@token, secret, true, algorithm: ALGORITHM) end |
#client_name ⇒ Object
9 10 11 |
# File 'lib/matic-jwt/authenticator.rb', line 9 def client_name payload.first['client_name'] end |