Skip to content

Commit 750e34c

Browse files
committed
comments
1 parent be01234 commit 750e34c

2 files changed

Lines changed: 12 additions & 7 deletions

File tree

dojo/backends.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ class Saml2Backend(_Saml2Backend):
1717

1818
@cached_property
1919
def group_re(self):
20-
if settings.SAML2_ENABLED and settings.SAML2_GROUPS_ATTRIBUTE and settings.SAML2_GROUPS_FILTER:
21-
return re.compile(settings.SAML2_GROUPS_FILTER)
20+
if settings.SAML2_ENABLED and settings.SAML2_GROUPS_ATTRIBUTE:
21+
if settings.SAML2_GROUPS_FILTER:
22+
return re.compile(settings.SAML2_GROUPS_FILTER)
23+
return re.compile(r".*")
2224
return None
2325

2426
def _update_user(
@@ -33,13 +35,16 @@ def _update_user(
3335
Ideally we would only override "public" methods: in this case, get_or_create_user() would be the one but it doesn't save the NEW user
3436
We could override that AND save_user() (each to handle new or existing users) but the latter does not receive the attributes which include the groups...
3537
36-
This does NOT create the groups if they do not exist. They have to be created in the UI
37-
This is not a big issue and it works around an existing bug with dojo/group/utils.py::group_post_save_handler (user does not yet exist and he is forcefully added to the new group - boom)
38+
Similar to AzureAD, this creates the matching SAML groups if they do not already exist.
3839
"""
3940
user = super()._update_user(user, attributes, attribute_mapping, force_save=force_save)
4041
if self.group_re is None:
4142
return user
4243

44+
self._process_user_groups(user, attributes)
45+
return user
46+
47+
def _process_user_groups(self, user, attributes):
4348
# list of all existing "SAML2-mapped" groups - regexp excluded so the ones no longer matching regexp are removed
4449
all_saml_groups = {group.name: group for group in Dojo_Group.objects.filter(social_provider=Dojo_Group.SAML)}
4550

dojo/settings/settings.dist.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,11 @@
196196
"Lastname": "last_name",
197197
}),
198198
DD_SAML2_ALLOW_UNKNOWN_ATTRIBUTE=(bool, False),
199+
# SAML2 attribute with groups to match in Dojo. If value is not set, no group processing is done.
200+
DD_SAML2_GROUPS_ATTRIBUTE=(str, ""),
199201
# similar to DD_SOCIAL_AUTH_AZUREAD_TENANT_OAUTH2_GROUPS_FILTER, regular expression for which SAML2 groups to map to Dojo groups (with same name)
200-
# Groups need to already exist in Dojo. And if value is not set, no group processing is done
202+
# Groups will be created if needed. If value is not set, any group will match.
201203
DD_SAML2_GROUPS_FILTER=(str, ""),
202-
# SAML2 attribute with groups to match in Dojo. And if value is not set, no group processing is done
203-
DD_SAML2_GROUPS_ATTRIBUTE=(str, ""),
204204
# Authentication via HTTP Proxy which put username to HTTP Header REMOTE_USER
205205
DD_AUTH_REMOTEUSER_ENABLED=(bool, False),
206206
# Names of headers which will be used for processing user data.

0 commit comments

Comments
 (0)