class ChronosAuthz::ACL

Attributes

acl_hash[RW]
records[RW]

Public Class Methods

build_from_yaml(acl_yaml = nil) click to toggle source
# File lib/chronos_authz/acl.rb, line 5
def self.build_from_yaml(acl_yaml = nil)
  acl_yaml ||= 'config/authorizer_acl.yml'
  acl_hash = YAML.load_file(acl_yaml)
  records = ACL.records_from_acl_hash(acl_hash)
  return ACL.new(records, acl_hash)
end
new(records = [], acl_hash = nil) click to toggle source
# File lib/chronos_authz/acl.rb, line 19
def initialize(records = [], acl_hash = nil)
  @records = records
  @acl_hash = acl_hash
end
records_from_acl_hash(acl_hash) click to toggle source

Populate @records with instances of ACL::Record and validate each instances

# File lib/chronos_authz/acl.rb, line 13
def self.records_from_acl_hash(acl_hash)
  return acl_hash.map do |record_name, record_options = {}| 
           ChronosAuthz::ACL::Record.new(record_options.merge!(name: record_name))
         end
end

Public Instance Methods

find_match(http_method, request_path) click to toggle source

Find matching ACL Record

# File lib/chronos_authz/acl.rb, line 25
def find_match(http_method, request_path)
  record = @records.select{ |record| record.matches?(http_method, request_path) }.first
  # puts "[ChronosAuthz] Found ACL match: #{record.to_s}" if record

  return record
end