Class: SoarAuthenticationToken::JwtTokenGenerator

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

Constant Summary collapse

DEFAULT_CONFIGURATION =
{
  'expiry' => 604800 #a days worth of seconds
}

Instance Method Summary collapse

Constructor Details

#initialize(configuration) ⇒ JwtTokenGenerator

Returns a new instance of JwtTokenGenerator.



12
13
14
15
16
# File 'lib/soar_authentication_token/providers/jwt_token_generator.rb', line 12

def initialize(configuration)
  @configuration = merge_with_default_configuration(configuration)
  validate_configuration
  @private_key = OpenSSL::PKey::EC.new(@configuration['private_key'])
end

Instance Method Details

#generate(authenticated_identifier:, flow_identifier: nil) ⇒ Object



22
23
24
25
26
27
# File 'lib/soar_authentication_token/providers/jwt_token_generator.rb', line 22

def generate(authenticated_identifier:, flow_identifier: nil)
  token_meta = generate_meta(authenticated_identifier)
  token = encode(token_meta)
  add_token_to_store(token_meta,flow_identifier)
  [token, token_meta]
end

#inject_store_provider(store_provider) ⇒ Object



18
19
20
# File 'lib/soar_authentication_token/providers/jwt_token_generator.rb', line 18

def inject_store_provider(store_provider)
  @store_provider = store_provider
end