Skip to content

Commit 7347b01

Browse files
committed
Switch to SPAWNER_ATTR which supports recursive attr check of spawner object
1 parent d7a15a2 commit 7347b01

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

ldap_hooks/hooks.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414

1515
SPAWNER_SUBMIT_DATA = '1'
1616
LDAP_SEARCH_ATTRIBUTE_QUERY = '2'
17-
SPAWNER_USER_STATE = '3'
17+
SPAWNER_ATTR = '3'
1818
DYNAMIC_ATTRIBUTE_METHODS = (SPAWNER_SUBMIT_DATA,
1919
LDAP_SEARCH_ATTRIBUTE_QUERY,
20-
SPAWNER_USER_STATE)
20+
SPAWNER_ATTR)
2121

2222
INCREMENT_ATTRIBUTE = '1'
2323
SEARCH_RESULT_OPERATION_ACTIONS = (INCREMENT_ATTRIBUTE,)
@@ -360,10 +360,10 @@ def get_interpolated_dynamic_attributes(logger, sources, dynamic_attributes):
360360
and sources[SPAWNER_SUBMIT_DATA]:
361361
val = get_dict_key(sources[SPAWNER_SUBMIT_DATA],
362362
attr_key)
363-
if attr_val == SPAWNER_USER_STATE:
364-
if SPAWNER_USER_STATE in sources \
365-
and sources[SPAWNER_USER_STATE]:
366-
val = get_dict_key(sources[SPAWNER_USER_STATE],
363+
if attr_val == SPAWNER_ATTR:
364+
if SPAWNER_ATTR in sources \
365+
and sources[SPAWNER_ATTR]:
366+
val = rec_get_attr(sources[SPAWNER_ATTR],
367367
attr_key)
368368
if not val:
369369
logger.error("LDAP - Missing {} in {} which is required for {} in"
@@ -578,7 +578,7 @@ def setup_ldap_entry_hook(spawner):
578578
# Extract attributes from existing object
579579
sources = {LDAP_SEARCH_ATTRIBUTE_QUERY: attributes,
580580
SPAWNER_SUBMIT_DATA: ldap_dict,
581-
SPAWNER_USER_STATE: spawner.user}
581+
SPAWNER_ATTR: spawner}
582582
spawner.log.debug("LDAP - dynamic_attributes "
583583
"pre interpolated: {}".format(
584584
instance.dynamic_attributes
@@ -659,7 +659,7 @@ def setup_ldap_entry_hook(spawner):
659659

660660
# Prepare required dynamic attributes
661661
sources.update({SPAWNER_SUBMIT_DATA: ldap_dict,
662-
SPAWNER_USER_STATE: spawner.user})
662+
SPAWNER_ATTR: spawner})
663663
spawner.log.debug("LDAP - Sources state before interpolating with "
664664
" dynamic attributes {}".format(sources))
665665
prepared_dynamic_attributes = get_interpolated_dynamic_attributes(

0 commit comments

Comments
 (0)