Class: SoarAuthenticationToken::StaticTokenValidator

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

Instance Method Summary collapse

Constructor Details

#initialize(configuration) ⇒ StaticTokenValidator

Returns a new instance of StaticTokenValidator.



3
4
5
6
# File 'lib/soar_authentication_token/providers/static_token_validator.rb', line 3

def initialize(configuration)
  @configuration = configuration
  validate_configuration
end

Instance Method Details

#inject_store_provider(store_provider) ⇒ Object



8
9
10
# File 'lib/soar_authentication_token/providers/static_token_validator.rb', line 8

def inject_store_provider(store_provider)
  #ignore the store provider since this validator does not use a store
end

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



12
13
14
15
16
17
18
19
20
21
# File 'lib/soar_authentication_token/providers/static_token_validator.rb', line 12

def validate(authentication_token:, request_information: nil, flow_identifier: nil)
  found_static_token = find_configured_static_token(authentication_token)
  return rejection_result(reason: 'Unknown static token') if found_static_token.nil?
  meta = compile_meta(token_identifier:         'static_token',
                      authenticated_identifier: found_static_token['authenticated_identifier'],
                      token_issue_time:         found_static_token['token_issue_time'],
                      token_expiry_time:        found_static_token['token_expiry_time'])
  return rejection_result(reason: "Expired token <#{meta['token_expiry_time']}> for <#{meta['authenticated_identifier']}>") if token_expired?(meta)
  return success_result(token_meta: meta)
end