Module: ApiKeys::Authentication
Overview
Controller concern for handling API key authentication.
Provides authenticate_api_key! method and helper methods.
Instance Method Summary collapse
-
#current_api_key ⇒ ApiKeys::ApiKey?
Returns the currently authenticated API key instance if authentication was successful, otherwise returns nil.
-
#current_api_owner ⇒ Object?
(also: #current_api_key_owner)
Returns the owner of the currently authenticated ApiKey, if any.
-
#current_api_user ⇒ User?
Convenience helper: returns the owner if it's a User instance.
Instance Method Details
#current_api_key ⇒ ApiKeys::ApiKey?
Returns the currently authenticated API key instance if authentication was successful, otherwise returns nil.
25 26 27 |
# File 'lib/api_keys/authentication.rb', line 25 def current_api_key @current_api_key end |
#current_api_owner ⇒ Object? Also known as: current_api_key_owner
Returns the owner of the currently authenticated ApiKey, if any.
31 32 33 |
# File 'lib/api_keys/authentication.rb', line 31 def current_api_owner current_api_key&.owner end |
#current_api_user ⇒ User?
Convenience helper: returns the owner if it's a User instance.
39 40 41 42 |
# File 'lib/api_keys/authentication.rb', line 39 def current_api_user owner = current_api_owner owner if defined?(::User) && owner.is_a?(::User) end |