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.



5
6
7
8
# File 'lib/matic-jwt/authenticator.rb', line 5

def initialize(header, scheme: SCHEME)
  @scheme = scheme
  @token = extract_token(header)
end

Instance Method Details

#authenticate_with_secret!(secret) ⇒ Object



14
15
16
# File 'lib/matic-jwt/authenticator.rb', line 14

def authenticate_with_secret!(secret)
  JWT.decode(@token, secret, true, algorithm: ALGORITHM)
end

#client_nameObject



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

def client_name
  payload.first['client_name']
end

#payloadObject



18
19
20
# File 'lib/matic-jwt/authenticator.rb', line 18

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