Class: Rails::Auth::ACL::Middleware
- Inherits:
-
Object
- Object
- Rails::Auth::ACL::Middleware
- Defined in:
- lib/rails/auth/acl/middleware.rb
Overview
Authorizes requests by matching them against the given ACL
Class Method Summary collapse
-
.from_acl_config(app, **args) ⇒ Object
Create Rails::Auth::ACL::Middleware from the args you’d pass to Rails::Auth::ACL’s constructor.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, acl: nil) ⇒ Rails::Auth::ACL::Middleware
constructor
Create a new ACL Middleware object.
Constructor Details
#initialize(app, acl: nil) ⇒ Rails::Auth::ACL::Middleware
Create a new ACL Middleware object
17 18 19 20 21 22 |
# File 'lib/rails/auth/acl/middleware.rb', line 17 def initialize(app, acl: nil) raise ArgumentError, "no acl given" unless acl @app = app @acl = acl end |
Class Method Details
Instance Method Details
#call(env) ⇒ Object
24 25 26 27 |
# File 'lib/rails/auth/acl/middleware.rb', line 24 def call(env) raise NotAuthorizedError, "unauthorized request" unless Rails::Auth.(env) || @acl.match(env) @app.call(env) end |