class ASF::Authorization

parse the -authorization-template files contained within infrastructure-puppet/modules/subversion_server/files/authorization

Constants

PUPPET_PATH

Public Class Methods

find_by_id(value) click to toggle source

Return the set of authorizations a given user (availid) has access to.

# File lib/whimsy/asf/auth.rb, line 11
def self.find_by_id(value)
  new.select {|_auth, ids| ids.include? value}.map(&:first)
end
new(file='asf', auth_path=nil) click to toggle source

Select a given -authorization-template, valid values are asf and pit. The optional auth_path parameter allows the directory path to be overridden This is intended for testing only

# File lib/whimsy/asf/auth.rb, line 19
def initialize(file='asf', auth_path=nil)
  raise ArgumentError("Invalid file: #{file}") unless %w(asf pit).include? file
  if auth_path
    require 'wunderbar'
    Wunderbar.warn "Overriding Git infrastructure-puppet auth path as: #{auth_path}"
    @auth = auth_path
  else
    @auth = PUPPET_PATH
  end
  @file = file
end

Public Instance Methods

each() { |pmc, (ids || '').split(' ')| ... } click to toggle source

Iteratively return each non_LDAP entry in the authorization file as a pair of values: a name and list of ids.

# File lib/whimsy/asf/auth.rb, line 33
def each
  # extract the xxx={auth} names
  groups = read_auth.scan(/^([-\w]+)=\{auth\}/).flatten
  # extract the group = list details and return the appropriate ones
  read_conf.scan(/^([-\w]+) *= *(\w.*)?$/).each do |pmc, ids|
    yield pmc, (ids || '').split(' ') if groups.include? pmc
  end
end
path() click to toggle source

Return the auth path used to find asf-auth and pit-auth

# File lib/whimsy/asf/auth.rb, line 43
def path
  @auth
end