mirror of
https://github.com/ansible/awx.git
synced 2026-05-23 16:47:45 -02:30
Updating comments and remove unneeded variable
This commit is contained in:
@@ -329,23 +329,26 @@ class SAMLAuth(BaseSAMLAuth):
|
|||||||
|
|
||||||
def _update_m2m_from_groups(ldap_user_group_dns, opts, remove=True):
|
def _update_m2m_from_groups(ldap_user_group_dns, opts, remove=True):
|
||||||
"""
|
"""
|
||||||
Hepler function to update m2m relationship based on LDAP group membership.
|
Hepler function to evaluate the LDAP team/org options to determine if LDAP user should
|
||||||
|
be a member of the team/org based on their ldap group dns.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
True - User should be added
|
||||||
|
False - User should be removed
|
||||||
|
None - Users membership should not be changed
|
||||||
"""
|
"""
|
||||||
should_add = False
|
|
||||||
if opts is None:
|
if opts is None:
|
||||||
return None
|
return None
|
||||||
elif not opts:
|
elif not opts:
|
||||||
pass
|
pass
|
||||||
elif isinstance(opts, bool) and opts is True:
|
elif isinstance(opts, bool) and opts is True:
|
||||||
should_add = True
|
return True
|
||||||
else:
|
else:
|
||||||
if isinstance(opts, str):
|
if isinstance(opts, str):
|
||||||
opts = [opts]
|
opts = [opts]
|
||||||
# If any of the users groups matches any of the list options
|
# If any of the users groups matches any of the list options
|
||||||
if list(set.intersection(set(ldap_user_group_dns), set(opts))):
|
if list(set.intersection(set(ldap_user_group_dns), set(opts))):
|
||||||
should_add = True
|
return True
|
||||||
if should_add:
|
|
||||||
return True
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
@@ -427,7 +430,7 @@ def on_populate_user(sender, **kwargs):
|
|||||||
remove_users = bool(org_opts.get('remove_users', remove))
|
remove_users = bool(org_opts.get('remove_users', remove))
|
||||||
desired_org_states[org_name]['member_role'] = _update_m2m_from_groups(ldap_user_group_dns, users_opts, remove_users)
|
desired_org_states[org_name]['member_role'] = _update_m2m_from_groups(ldap_user_group_dns, users_opts, remove_users)
|
||||||
|
|
||||||
# If everything returned None (because there was no configuration) we can skip this host
|
# If everything returned None (because there was no configuration) we can remove this org from our map
|
||||||
if (
|
if (
|
||||||
desired_org_states[org_name]['admin_role'] == None
|
desired_org_states[org_name]['admin_role'] == None
|
||||||
and desired_org_states[org_name]['auditor_role'] == None
|
and desired_org_states[org_name]['auditor_role'] == None
|
||||||
|
|||||||
Reference in New Issue
Block a user