Class: Aker::Rack::Authenticate
- Inherits:
-
Object
- Object
- Aker::Rack::Authenticate
- Includes:
- EnvironmentHelper
- Defined in:
- lib/aker/rack/authenticate.rb
Overview
The middleware which actually performs authentication according to the mode that applies to the request (if any). Most of the heavy lifting is performed by Warden.
Instance Method Summary collapse
-
#call(env) ⇒ Object
Authenticates incoming requests using Warden.
-
#initialize(app) ⇒ Authenticate
constructor
A new instance of Authenticate.
Methods included from EnvironmentHelper
#authority, #configuration, #interactive?
Constructor Details
#initialize(app) ⇒ Authenticate
Returns a new instance of Authenticate.
11 12 13 |
# File 'lib/aker/rack/authenticate.rb', line 11 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
Authenticates incoming requests using Warden.
Additionally, this class exposes the ‘aker.check` environment variable to downstream middleware and the app. It is an instance of Facade permitting authentication and authorization queries about the current user (if any).
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/aker/rack/authenticate.rb', line 22 def call(env) configuration = configuration(env) warden = env['warden'] if interactive?(env) warden.authenticate(configuration.ui_mode) else warden.authenticate(*configuration.api_modes) end env['aker.check'] = Facade.new(configuration, warden.user) @app.call(env) end |