Class: MaticJWT::Authenticator
- Inherits:
-
Object
- Object
- MaticJWT::Authenticator
- Defined in:
- lib/matic-jwt/authenticator.rb
Instance Method Summary collapse
- #authenticate_with_secret!(secret) ⇒ Object
- #client_name ⇒ Object
-
#initialize(header, scheme: SCHEME) ⇒ Authenticator
constructor
A new instance of Authenticator.
- #payload ⇒ Object
Constructor Details
#initialize(header, scheme: SCHEME) ⇒ Authenticator
Returns a new instance of Authenticator.
3 4 5 6 |
# File 'lib/matic-jwt/authenticator.rb', line 3 def initialize(header, scheme: SCHEME) @scheme = scheme @token = extract_token(header) end |
Instance Method Details
#authenticate_with_secret!(secret) ⇒ Object
12 13 14 |
# File 'lib/matic-jwt/authenticator.rb', line 12 def authenticate_with_secret!(secret) JWT.decode(@token, secret, true, algorithm: ALGORITHM) end |
#client_name ⇒ Object
8 9 10 |
# File 'lib/matic-jwt/authenticator.rb', line 8 def client_name payload.first['client_name'] end |
#payload ⇒ Object
16 17 18 |
# File 'lib/matic-jwt/authenticator.rb', line 16 def payload JWT.decode(@token, nil, false) end |