adapters: add a separate method to remove superuser flags
So that we can override it somewhere else.
This commit is contained in:
parent
0f26806791
commit
2aae735841
|
@ -185,7 +185,6 @@ class DefaultAdapter(object):
|
|||
superuser_mapping = utils.get_setting(idp, 'SUPERUSER_MAPPING')
|
||||
if not superuser_mapping:
|
||||
return
|
||||
attribute_set = False
|
||||
for key, values in superuser_mapping.items():
|
||||
if key in saml_attributes:
|
||||
if not isinstance(values, (tuple, list)):
|
||||
|
@ -199,16 +198,17 @@ class DefaultAdapter(object):
|
|||
if not (user.is_staff and user.is_superuser):
|
||||
user.is_staff = True
|
||||
user.is_superuser = True
|
||||
attribute_set = True
|
||||
user.save()
|
||||
self.logger.info('flag is_staff and is_superuser added to user %s', user)
|
||||
break
|
||||
else:
|
||||
if user.is_superuser or user.is_staff:
|
||||
user.is_staff = False
|
||||
user.is_superuser = False
|
||||
self.logger.info('flag is_staff and is_superuser removed from user %s', user)
|
||||
attribute_set = True
|
||||
if attribute_set:
|
||||
self.remove_superuser(user)
|
||||
|
||||
def remove_superuser(self, user):
|
||||
if user.is_superuser or user.is_staff:
|
||||
user.is_staff = False
|
||||
user.is_superuser = False
|
||||
self.logger.info('flag is_staff and is_superuser removed from user %s', user)
|
||||
user.save()
|
||||
|
||||
def provision_groups(self, user, idp, saml_attributes):
|
||||
|
|
Loading…
Reference in New Issue