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
-
#current_api_key ⇒ Object
readonly
Returns the value of attribute current_api_key.
-
#current_bearer ⇒ Object
readonly
Returns the value of attribute current_bearer.
Instance Method Summary collapse
-
#authenticate_with_api_key ⇒ Object
Use this for optional API key authentication.
-
#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.
Instance Attribute Details
#current_api_key ⇒ Object
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_bearer ⇒ Object
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_key ⇒ Object
Use this for optional API key authentication
24 25 26 27 |
# File 'lib/itg/itg_api_key_authenticatable.rb', line 24 def authenticate_with_api_key @current_bearer = authenticate_with_http_token(&method(:authenticator)) Current.user = @current_bearer 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 19 20 21 |
# 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)) Current.user = @current_bearer puts ">>>> authenticate_with_api_key! - params: #{params}" # Current.context = end |