From db53d4d024b992b27f81bb0e6f524206ff2a69a4 Mon Sep 17 00:00:00 2001 From: Jacob LeMire <88508497+jlemire3@users.noreply.github.com> Date: Tue, 19 Nov 2024 13:24:38 -0800 Subject: [PATCH] Change "FLAGS_BY_GROUP" in backends.py to accept array of groups This commit changes the logic of the "FLAGS_BY_GROUP" parameter such that it can accept an array of group names. This will allow multiple groups to be configured with the respective flag. --- django3_saml2_nbplugin/backends.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/django3_saml2_nbplugin/backends.py b/django3_saml2_nbplugin/backends.py index de0eed8..364b11d 100644 --- a/django3_saml2_nbplugin/backends.py +++ b/django3_saml2_nbplugin/backends.py @@ -171,8 +171,10 @@ def configure_user(self, request: WSGIRequest, user: User) -> User: pass if "FLAGS_BY_GROUP" in be_settings and "GROUP_ATTR" in be_settings: - for flag, group_name in be_settings["FLAGS_BY_GROUP"].items(): - if group_name in ident_groups: + for flag, group_names in be_settings["FLAGS_BY_GROUP"].items(): + if not isinstance(group_names, list): + group_names = [group_names] + if any(group_name in ident_groups for group_name in group_names): setattr(user, flag, True) else: setattr(user, flag, False)