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')
|
superuser_mapping = utils.get_setting(idp, 'SUPERUSER_MAPPING')
|
||||||
if not superuser_mapping:
|
if not superuser_mapping:
|
||||||
return
|
return
|
||||||
attribute_set = False
|
|
||||||
for key, values in superuser_mapping.items():
|
for key, values in superuser_mapping.items():
|
||||||
if key in saml_attributes:
|
if key in saml_attributes:
|
||||||
if not isinstance(values, (tuple, list)):
|
if not isinstance(values, (tuple, list)):
|
||||||
|
@ -199,16 +198,17 @@ class DefaultAdapter(object):
|
||||||
if not (user.is_staff and user.is_superuser):
|
if not (user.is_staff and user.is_superuser):
|
||||||
user.is_staff = True
|
user.is_staff = True
|
||||||
user.is_superuser = True
|
user.is_superuser = True
|
||||||
attribute_set = True
|
user.save()
|
||||||
self.logger.info('flag is_staff and is_superuser added to user %s', user)
|
self.logger.info('flag is_staff and is_superuser added to user %s', user)
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
if user.is_superuser or user.is_staff:
|
self.remove_superuser(user)
|
||||||
user.is_staff = False
|
|
||||||
user.is_superuser = False
|
def remove_superuser(self, user):
|
||||||
self.logger.info('flag is_staff and is_superuser removed from user %s', user)
|
if user.is_superuser or user.is_staff:
|
||||||
attribute_set = True
|
user.is_staff = False
|
||||||
if attribute_set:
|
user.is_superuser = False
|
||||||
|
self.logger.info('flag is_staff and is_superuser removed from user %s', user)
|
||||||
user.save()
|
user.save()
|
||||||
|
|
||||||
def provision_groups(self, user, idp, saml_attributes):
|
def provision_groups(self, user, idp, saml_attributes):
|
||||||
|
|
Loading…
Reference in New Issue