Class: ApiKeys::Services::Authenticator::Result
- Inherits:
-
Struct
- Object
- Struct
- ApiKeys::Services::Authenticator::Result
- Defined in:
- lib/api_keys/services/authenticator.rb
Overview
Result object for authentication attempts.
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#error_code ⇒ Object
Returns the value of attribute error_code.
-
#message ⇒ Object
Returns the value of attribute message.
-
#success? ⇒ Object
Returns the value of attribute success?.
Class Method Summary collapse
-
.failure(error_code:, message:, api_key: nil) ⇒ Object
api_keyis present when the key WAS identified and a policy check refused it (environment isolation, request restrictions): the after_authentication callback then reports WHICH key was refused, exactly as it already does for scope refusals. - .success(api_key) ⇒ Object
Instance Method Summary collapse
-
#inspect ⇒ Object
(also: #to_s)
Do not delegate to Struct's default inspection: it recursively inspects the Active Record object and can expose token digests or public tokens.
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key
24 25 26 |
# File 'lib/api_keys/services/authenticator.rb', line 24 def api_key @api_key end |
#error_code ⇒ Object
Returns the value of attribute error_code
24 25 26 |
# File 'lib/api_keys/services/authenticator.rb', line 24 def error_code @error_code end |
#message ⇒ Object
Returns the value of attribute message
24 25 26 |
# File 'lib/api_keys/services/authenticator.rb', line 24 def @message end |
#success? ⇒ Object
Returns the value of attribute success?
24 25 26 |
# File 'lib/api_keys/services/authenticator.rb', line 24
def success?
@success?
end
|
Class Method Details
.failure(error_code:, message:, api_key: nil) ⇒ Object
api_key is present when the key WAS identified and a policy check
refused it (environment isolation, request restrictions): the
after_authentication callback then reports WHICH key was refused,
exactly as it already does for scope refusals. Lookup failures have
no key to name, so they leave it nil.
34 35 36 |
# File 'lib/api_keys/services/authenticator.rb', line 34 def self.failure(error_code:, message:, api_key: nil) new(success?: false, error_code: error_code, message: , api_key: api_key) end |
.success(api_key) ⇒ Object
25 26 27 |
# File 'lib/api_keys/services/authenticator.rb', line 25 def self.success(api_key) new(success?: true, api_key: api_key) end |
Instance Method Details
#inspect ⇒ Object Also known as: to_s
Do not delegate to Struct's default inspection: it recursively inspects the Active Record object and can expose token digests or public tokens.
40 41 42 |
# File 'lib/api_keys/services/authenticator.rb', line 40 def inspect "#<#{self.class.name} success?=#{success?.inspect} api_key_id=#{api_key&.id.inspect} error_code=#{error_code.inspect}>" end |