Class: PactBroker::Api::Authorization::ResourceAccessRules

Inherits:
Object
  • Object
show all
Defined in:
lib/pact_broker/api/authorization/resource_access_rules.rb

Constant Summary collapse

PATH_INFO =
Rack::PATH_INFO
REQUEST_METHOD =
Rack::REQUEST_METHOD

Instance Method Summary collapse

Constructor Details

#initialize(rules) ⇒ ResourceAccessRules

Returns a new instance of ResourceAccessRules.



10
11
12
# File 'lib/pact_broker/api/authorization/resource_access_rules.rb', line 10

def initialize(rules)
  @rules = rules
end

Instance Method Details

#access_allowed?(env, level) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
17
18
19
20
# File 'lib/pact_broker/api/authorization/resource_access_rules.rb', line 14

def access_allowed?(env, level)
  !!rules.find do | rule_level, allowed_methods, path_pattern |
    level_allowed?(level, rule_level) &&
      method_allowed?(env, allowed_methods) &&
      path_allowed?(env, path_pattern)
  end
end