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.



14
15
16
17
18
# File 'lib/soar_authentication_token/providers/jwt_token_generator.rb', line 14

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

Instance Method Details

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



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

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



20
21
22
# File 'lib/soar_authentication_token/providers/jwt_token_generator.rb', line 20

def inject_store_provider(store_provider)
  @store_provider = store_provider
end