Class: BoltServer::ACL

Inherits:
Rails::Auth::ErrorPage::Middleware
  • Object
show all
Defined in:
lib/bolt_server/acl.rb

Defined Under Namespace

Classes: X509Matcher

Instance Method Summary collapse

Constructor Details

#initialize(app, allowlist) ⇒ ACL

Returns a new instance of ACL.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/bolt_server/acl.rb', line 19

def initialize(app, allowlist)
  acls = []
  allowlist.each do |entry|
    acls << {
      'resources' => [
        {
          'method' => 'ALL',
          'path' => '/.*'
        }
      ],
      'allow_x509_subject' => {
        'cn' => entry
      }
    }
  end
  acl = Rails::Auth::ACL.new(acls, matchers: { allow_x509_subject: X509Matcher })
  mid = Rails::Auth::ACL::Middleware.new(app, acl: acl)
  super(mid, page_body: 'Access denied')
end