Class: Aker::Modes::Base
- Inherits:
-
Warden::Strategies::Base
- Object
- Warden::Strategies::Base
- Aker::Modes::Base
- Includes:
- Rack::EnvironmentHelper
- Defined in:
- lib/aker/modes/base.rb
Overview
Base class for all authentication modes.
An _authentication mode_ is an an object that implements an authentication protocol. Modes may be interactive, meaning that they require input from a human, and/or non-interactive, meaning that they can be used without user intervention.
For mode implementors: While it is not strictly necessary to implement aker modes as subclasses of ‘Aker::Modes::Base`, it is recommended that you do so.
Direct Known Subclasses
Instance Method Summary collapse
-
#authenticate! ⇒ void
Authenticates a user.
-
#authority ⇒ Object
Exposes the authority this mode will use to validate credentials.
-
#configuration ⇒ Aker::Configuration
Exposes the configuration this mode should use.
-
#interactive? ⇒ Boolean
Whether or not the current request is interactive.
-
#store? ⇒ Boolean
Used by Warden to determine whether or not it should store user information in the session.
Instance Method Details
#authenticate! ⇒ void
This method returns an undefined value.
Authenticates a user.
#authenticate! expects ‘kind` and `credentials` to be defined. See subclasses for examples.
If authentication is successful, then success! (from ‘Warden::Strategies::Base`) is called with a User object. If authentication fails, then nothing is done.
79 80 81 82 |
# File 'lib/aker/modes/base.rb', line 79 def authenticate! user = .valid_credentials?(kind, *credentials) success!(user) if user end |
#authority ⇒ Object
Exposes the authority this mode will use to validate credentials. Internally it is extracted from the ‘aker.authority` Rack environment variable.
36 37 38 |
# File 'lib/aker/modes/base.rb', line 36 def super(env) end |
#configuration ⇒ Aker::Configuration
Exposes the configuration this mode should use.
26 27 28 |
# File 'lib/aker/modes/base.rb', line 26 def configuration super(env) end |
#interactive? ⇒ Boolean
Whether or not the current request is interactive.
44 45 46 |
# File 'lib/aker/modes/base.rb', line 44 def interactive? super(env) end |
#store? ⇒ Boolean
Used by Warden to determine whether or not it should store user information in the session. In Aker, this is computed as the result of #interactive?.
N.B. The ‘!!` is present because Warden requires that this method return `false` (not `false` or `nil`) for session serialization to be disabled.
64 65 66 |
# File 'lib/aker/modes/base.rb', line 64 def store? !!interactive? end |