Class: MaticJWT::Authenticator

Inherits:
Object
  • Object
show all
Defined in:
lib/matic-jwt/authenticator.rb

Constant Summary collapse

TOKEN_TYPE =
'Bearer: '.freeze

Instance Method Summary collapse

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_nameObject



9
10
11
# File 'lib/matic-jwt/authenticator.rb', line 9

def client_name
  payload.first['client_name']
end