Class: MaticJWT::Authenticator

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

Instance Method Summary collapse

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_nameObject


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

def client_name
  payload.first['client_name']
end

#payloadObject


16
17
18
# File 'lib/matic-jwt/authenticator.rb', line 16

def payload
  JWT.decode(@token, nil, false)
end