mirror of
https://github.com/ansible/awx.git
synced 2026-07-29 08:59:55 -02:30
convert py2 -> py3
This commit is contained in:
@@ -40,11 +40,11 @@ logger = logging.getLogger('awx.sso.backends')
|
||||
|
||||
class LDAPSettings(BaseLDAPSettings):
|
||||
|
||||
defaults = dict(BaseLDAPSettings.defaults.items() + {
|
||||
defaults = dict(list(BaseLDAPSettings.defaults.items()) + list({
|
||||
'ORGANIZATION_MAP': {},
|
||||
'TEAM_MAP': {},
|
||||
'GROUP_TYPE_PARAMS': {},
|
||||
}.items())
|
||||
}.items()))
|
||||
|
||||
def __init__(self, prefix='AUTH_LDAP_', defaults={}):
|
||||
super(LDAPSettings, self).__init__(prefix, defaults)
|
||||
@@ -117,7 +117,7 @@ class LDAPBackend(BaseLDAPBackend):
|
||||
raise ImproperlyConfigured(
|
||||
"{} must be an {} instance.".format(setting_name, type_)
|
||||
)
|
||||
return super(LDAPBackend, self).authenticate(username, password)
|
||||
return super(LDAPBackend, self).authenticate(None, username, password)
|
||||
except Exception:
|
||||
logger.exception("Encountered an error authenticating to LDAP")
|
||||
return None
|
||||
@@ -198,7 +198,7 @@ class RADIUSBackend(BaseRADIUSBackend):
|
||||
if not feature_enabled('enterprise_auth'):
|
||||
logger.error("Unable to authenticate, license does not support RADIUS authentication")
|
||||
return None
|
||||
return super(RADIUSBackend, self).authenticate(username, password)
|
||||
return super(RADIUSBackend, self).authenticate(None, username, password)
|
||||
|
||||
def get_user(self, user_id):
|
||||
if not django_settings.RADIUS_SERVER:
|
||||
@@ -228,16 +228,16 @@ class TACACSPlusBackend(object):
|
||||
try:
|
||||
# Upstream TACACS+ client does not accept non-string, so convert if needed.
|
||||
auth = tacacs_plus.TACACSClient(
|
||||
django_settings.TACACSPLUS_HOST.encode('utf-8'),
|
||||
django_settings.TACACSPLUS_HOST,
|
||||
django_settings.TACACSPLUS_PORT,
|
||||
django_settings.TACACSPLUS_SECRET.encode('utf-8'),
|
||||
django_settings.TACACSPLUS_SECRET,
|
||||
timeout=django_settings.TACACSPLUS_SESSION_TIMEOUT,
|
||||
).authenticate(
|
||||
username.encode('utf-8'), password.encode('utf-8'),
|
||||
username, password,
|
||||
authen_type=tacacs_plus.TAC_PLUS_AUTHEN_TYPES[django_settings.TACACSPLUS_AUTH_PROTOCOL],
|
||||
)
|
||||
except Exception as e:
|
||||
logger.exception("TACACS+ Authentication Error: %s" % (e.message,))
|
||||
logger.exception("TACACS+ Authentication Error: %s" % str(e))
|
||||
return None
|
||||
if auth.valid:
|
||||
return _get_or_set_enterprise_user(username, password, 'tacacs+')
|
||||
@@ -341,8 +341,10 @@ def _update_m2m_from_groups(user, ldap_user, rel, opts, remove=True):
|
||||
if ldap_user._get_groups().is_member_of(group_dn):
|
||||
should_add = True
|
||||
if should_add:
|
||||
user.save()
|
||||
rel.add(user)
|
||||
elif remove and user in rel.all():
|
||||
user.save()
|
||||
rel.remove(user)
|
||||
|
||||
|
||||
@@ -398,6 +400,7 @@ def on_populate_user(sender, **kwargs):
|
||||
remove)
|
||||
|
||||
# Update user profile to store LDAP DN.
|
||||
user.save()
|
||||
profile = user.profile
|
||||
if profile.ldap_dn != ldap_user.dn:
|
||||
profile.ldap_dn = ldap_user.dn
|
||||
|
||||
Reference in New Issue
Block a user