Skip to content

Commit

Permalink
Allow chained auth functions to chain off built-in auth functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
ashleysommer authored and frafra committed Jan 9, 2019
1 parent a11a038 commit 4c7c42a
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions ckan/authz.py
Expand Up @@ -102,13 +102,19 @@ def _build(self):
fetched_auth_functions[name] = auth_function

for name, func_list in chained_auth_functions.iteritems():
if name not in fetched_auth_functions:
if name not in fetched_auth_functions and\
name not in self._functions:
raise Exception('The auth %r is not found for chained auth' % (
name))
# create the chain of functions in the correct order
for func in reversed(func_list):
prev_func = fetched_auth_functions[name]
fetched_auth_functions[name] = functools.partial(func, prev_func)
if name in fetched_auth_functions:
prev_func = fetched_auth_functions[name]
else:
# fallback to chaining off the builtin auth function
prev_func = self._functions[name]
fetched_auth_functions[name] =\
functools.partial(func, prev_func)

# Use the updated ones in preference to the originals.
self._functions.update(fetched_auth_functions)
Expand Down

0 comments on commit 4c7c42a

Please sign in to comment.