in authz.py [0:0]
def __init__(self, cfg, verbose=0):
self.cfg = cfg
def verbose2(*args):
if verbose >= 2: print(*args)
self.verbose2 = verbose2
# Gather up a bunch of changes, then write new files. We want to
# avoid writing for each change. Gather them up for a bit of time,
# then dump the group of changes into the new authz files.
self.delay = cfg['config']['delay']
self.verbose2('DELAY:', self.delay)
url = cfg['config']['ldap']
self.verbose2('LDAP:', url)
self.verbose2('AUTH:', cfg['special']['auth'])
self.verbose2('GROUPS:', cfg['special']['groups'])
self.verbose2('SERVICES:', cfg['special']['services'])
self.verbose2('EXPLICIT:', cfg['explicit'])
special = { a: self.DN_AUTH for a in cfg['special']['auth'] }
special.update((g, self.DN_GROUPS) for g in cfg['special']['groups'])
special.update((s, self.DN_SERVICES) for s in cfg['special']['services'])
self.gen = gen.Generator(url,
cfg['config']['binddn'],
cfg['config']['bindpw'],
special,
cfg['explicit'],
)
self.auth = (cfg['generate']['template_username'],
cfg['generate']['template_password'],
)
turl = cfg['generate']['template_url']
odir = cfg['generate']['output_dir']
LOGGER.debug(f'TURL: {turl}\nODIR: {odir}')
self.dist_authz = os.path.join(odir, cfg['generate']['dist_output'])
self.mappings = { }
for name in cfg['generate']:
ob = cfg['generate'][name]
if isinstance(ob, dict):
# Note: NAME is unused, except as a descriptor/grouping
t = turl + ob['template']
o = os.path.join(odir, ob['output'])
self.mappings[t] = o
# Write new authz files on startup.
self.write_signal = 0 # epoch