Allow mapping org auditors where we map org admins.

This commit is contained in:
Bill Nottingham
2019-07-18 15:06:21 -04:00
parent 0cc9199f23
commit bbf28f50bd
5 changed files with 18 additions and 1 deletions

View File

@@ -151,17 +151,20 @@ def update_user_orgs_by_saml_attr(backend, details, user=None, *args, **kwargs):
return
from django.conf import settings
org_map = settings.SOCIAL_AUTH_SAML_ORGANIZATION_ATTR
if org_map.get('saml_attr') is None and org_map.get('saml_admin_attr') is None:
if org_map.get('saml_attr') is None and org_map.get('saml_admin_attr') is None and org_map.get('saml_auditor_attr') is None:
return
remove = bool(org_map.get('remove', True))
remove_admins = bool(org_map.get('remove_admins', True))
remove_auditors = bool(org_map.get('remove_auditors', True))
attr_values = kwargs.get('response', {}).get('attributes', {}).get(org_map['saml_attr'], [])
attr_admin_values = kwargs.get('response', {}).get('attributes', {}).get(org_map['saml_admin_attr'], [])
attr_auditor_values = kwargs.get('response', {}).get('attributes', {}).get(org_map['saml_auditor_attr'], [])
_update_org_from_attr(user, "member_role", attr_values, remove, False)
_update_org_from_attr(user, "admin_role", attr_admin_values, False, remove_admins)
_update_org_from_attr(user, "auditor_role", attr_auditor_values, False, remove_auditors)
def update_user_teams_by_saml_attr(backend, details, user=None, *args, **kwargs):