Commit c8cab084 authored by Ryan Goggin's avatar Ryan Goggin

Add adfs backend and fix saml backend

parent 330a8f2a
from django_auth_adfs.backend import AdfsAuthCodeBackend
from django_auth_adfs.config import settings, provider_config
from uw_saml_tools.utils import sync_user_groups
class ADFSBackend(AdfsAuthCodeBackend):
def update_user_groups(self, user, claims):
if settings.GROUPS_CLAIM in claims:
claim_groups = claims[settings.GROUPS_CLAIM]
if not isinstance(claim_groups, list):
claim_groups = [claim_groups,]
sync_user_groups(user, claim_groups)
......@@ -19,7 +19,7 @@ class Saml2Backend(djsaml2Backend):
to_remove.append(saml_attr)
for remove in to_remove:
del attribute_mapping[remove]
del attributes[remove]
return super(Saml2Backend, self).update_user(user, attributes, attribute_mapping, force_save)
......@@ -24,7 +24,7 @@ def sync_user_groups(user, saml_list):
add_groups = distinct_sync.difference(set(groups))
for rg in remove_groups:
rg.user_set.remove(user)
user.groups.remove(rg)
for ag in add_groups:
ag.user_set.add(user)
user.groups.add(ag)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment