From d896b9033f533842d82ffa30c74029b9ab983480 Mon Sep 17 00:00:00 2001 From: YI Date: Thu, 6 Jun 2019 13:54:15 +0800 Subject: [PATCH] add superuser list support changed trigger running order --- django_saml2_auth/views.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/django_saml2_auth/views.py b/django_saml2_auth/views.py index 865c112..92a060e 100644 --- a/django_saml2_auth/views.py +++ b/django_saml2_auth/views.py @@ -149,6 +149,7 @@ def _create_new_user(username, email, firstname, lastname): user.is_active = settings.SAML2_AUTH.get('NEW_USER_PROFILE', {}).get('ACTIVE_STATUS', True) user.is_staff = settings.SAML2_AUTH.get('NEW_USER_PROFILE', {}).get('STAFF_STATUS', True) user.is_superuser = settings.SAML2_AUTH.get('NEW_USER_PROFILE', {}).get('SUPERUSER_STATUS', False) + user.is_superuser = user.is_superuser or username in settings.SAML2_AUTH.get('NEW_USER_PROFILE', {}).get('SUPERUSERS', []) user.save() return user @@ -180,9 +181,9 @@ def acs(r): is_new_user = False try: - target_user = User.objects.get(username=user_name) if settings.SAML2_AUTH.get('TRIGGER', {}).get('BEFORE_LOGIN', None): import_string(settings.SAML2_AUTH['TRIGGER']['BEFORE_LOGIN'])(user_identity) + target_user = User.objects.get(username=user_name) except User.DoesNotExist: new_user_should_be_created = settings.SAML2_AUTH.get('CREATE_USER', True) if new_user_should_be_created: