more efficiently determine saml team mapping

This commit is contained in:
Chris Meyers
2018-01-09 10:45:10 -05:00
parent 664bdec57f
commit 0a9d3d47b9

View File

@@ -186,12 +186,15 @@ def update_user_teams_by_saml_attr(backend, details, user=None, *args, **kwargs)
if team_map.get('saml_attr') is None: if team_map.get('saml_attr') is None:
return return
attr_values = kwargs.get('response', {}).get('attributes', {}).get(team_map['saml_attr'], []) saml_team_names = set(kwargs
.get('response', {})
.get('attributes', {})
.get(team_map['saml_attr'], []))
team_ids = [] team_ids = []
for team_name in attr_values:
for team_name_map in team_map.get('team_org_map', []): for team_name_map in team_map.get('team_org_map', []):
if team_name_map.get('team', '') == team_name: team_name = team_name_map.get('team', '')
if team_name in saml_team_names:
if multiple_orgs: if multiple_orgs:
if not team_name_map.get('organization', ''): if not team_name_map.get('organization', ''):
# Settings field validation should prevent this. # Settings field validation should prevent this.