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
19 20 21 22 23 24 |
# File 'lib/rails/auth/acl/middleware.rb', line 19 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
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/rails/auth/acl/middleware.rb', line 26 def call(env) unless Rails::Auth.(env) matcher_name = @acl.match(env) raise NotAuthorizedError, "unauthorized request" unless matcher_name Rails::Auth.set_allowed_by(env, "matcher:#{matcher_name}") end @app.call(env) end |