Sha256: 532dc713d9149b54bbd6743d7a9971df04fd2ae704c84734a02086c84e9fb82c
Contents?: true
Size: 961 Bytes
Versions: 3
Compression:
Stored size: 961 Bytes
Contents
module Rails module Auth class ACL # Authorizes requests by matching them against the given ACL class Middleware # Create Rails::Auth::ACL::Middleware from the args you'd pass to Rails::Auth::ACL's constructor def self.from_acl_config(app, **args) new(app, acl: Rails::Auth::ACL.new(**args)) end # Create a new ACL Middleware object # # @param [Object] app next app in the Rack middleware chain # @param [Hash] acl Rails::Auth::ACL object to authorize the request with # # @return [Rails::Auth::ACL::Middleware] new ACL middleware instance def initialize(app, acl: nil) fail ArgumentError, "no acl given" unless acl @app = app @acl = acl end def call(env) fail NotAuthorizedError, "unauthorized request" unless @acl.match(env) @app.call(env) end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rails-auth-0.2.0 | lib/rails/auth/acl/middleware.rb |
rails-auth-0.1.0 | lib/rails/auth/acl/middleware.rb |
rails-auth-0.0.1 | lib/rails/auth/acl/middleware.rb |