Module: Itg::ApiKeyAuthenticatable

Extended by:
ActiveSupport::Concern
Includes:
ActionController::HttpAuthentication::Basic::ControllerMethods, ActionController::HttpAuthentication::Token::ControllerMethods
Defined in:
lib/itg/itg_api_key_authenticatable.rb

Overview

Api Key Authenticatable class

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#current_api_keyObject

Returns the value of attribute current_api_key.



11
12
13
# File 'lib/itg/itg_api_key_authenticatable.rb', line 11

def current_api_key
  @current_api_key
end

#current_bearerObject

Returns the value of attribute current_bearer.



12
13
14
# File 'lib/itg/itg_api_key_authenticatable.rb', line 12

def current_bearer
  @current_bearer
end

Instance Method Details

#authenticate_with_api_keyObject

Use this for optional API key authentication



21
22
23
# File 'lib/itg/itg_api_key_authenticatable.rb', line 21

def authenticate_with_api_key
  @current_bearer = authenticate_with_http_token(&method(:authenticator))
end

#authenticate_with_api_key!Object

Use this to raise an error and automatically respond with a 401 HTTP status code when API key authentication fails



16
17
18
# File 'lib/itg/itg_api_key_authenticatable.rb', line 16

def authenticate_with_api_key!
  @current_bearer = authenticate_or_request_with_http_token(&method(:authenticator))
end