Class: SoarAuthenticationToken::JwtTokenValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/soar_authentication_token/providers/jwt_token_validator.rb

Instance Method Summary collapse

Constructor Details

#initialize(configuration) ⇒ JwtTokenValidator

Returns a new instance of JwtTokenValidator.



5
6
7
8
9
# File 'lib/soar_authentication_token/providers/jwt_token_validator.rb', line 5

def initialize(configuration)
  @configuration = configuration
  set_configuration_defaults
  validate_configuration
end

Instance Method Details

#inject_store_provider(store_provider) ⇒ Object



11
12
13
# File 'lib/soar_authentication_token/providers/jwt_token_validator.rb', line 11

def inject_store_provider(store_provider)
  @store_provider = store_provider
end

#validate(authentication_token:, flow_identifier:, request_information:) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/soar_authentication_token/providers/jwt_token_validator.rb', line 15

def validate(authentication_token:,flow_identifier:, request_information:)
  decoded_token_payload = decode(authentication_token)
  return rejection_result(reason: 'Token decode/verification failure') if decoded_token_payload.nil?
  meta = compile_meta_from_payload(decoded_token_payload)
  return rejection_result(reason: "Expired token <#{meta['token_expiry_time']}> for <#{meta['authenticated_identifier']}>") if token_expired?(meta)
  return rejection_result(reason: "Unknown token for <#{meta['authenticated_identifier']}>") unless token_exist_in_store?(meta,flow_identifier)
  success_result(token_meta: meta)
end