Skip to content

Commit

Permalink
add superuser list support
Browse files Browse the repository at this point in the history
changed trigger running order
  • Loading branch information
contrun committed Jun 6, 2019
1 parent 825c109 commit d896b90
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion django_saml2_auth/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit d896b90

Please sign in to comment.