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?
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?
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.
37 38 39 40 |
# File 'lib/api_keys/authentication.rb', line 37 def current_api_user owner = current_api_owner owner if owner.is_a?(::User) # Assumes a User class exists end |