Class: SoarAuthenticationToken::CookieProvider

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

Instance Method Summary collapse

Constructor Details

#initialize(configuration) ⇒ CookieProvider

Returns a new instance of CookieProvider.



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

def initialize(configuration)
  @configuration = configuration
  validate_configuration
end

Instance Method Details

#fetch(request) ⇒ Object



10
11
12
13
14
15
# File 'lib/soar_authentication_token/providers/cookie_provider.rb', line 10

def fetch(request)
  return false unless request.env.has_key?('HTTP_COOKIE')
  return false unless request.cookies.has_key?(@configuration['cookie_name'])

  request.cookies[@configuration['cookie_name']]
end

#validate_configurationObject



17
18
19
# File 'lib/soar_authentication_token/providers/cookie_provider.rb', line 17

def validate_configuration
  raise "'cookie_name' must be configured" unless @configuration['cookie_name']
end