mirror of
https://github.com/ansible/awx.git
synced 2026-05-15 21:37:42 -02:30
fix an LDAP settings bug which can cause LDAP auth to fail
django-ldap-auth expects the "unset/empty" state of certain LDAP DN settings (such as AUTH_LDAP_REQUIRE_GROUP and AUTH_LDAP_USER_DN_TEMPLATE) to be NULL/None (not an empty string). Resolves #4678
This commit is contained in:
@@ -153,6 +153,12 @@ class LDAPDNField(fields.CharField):
|
||||
super(LDAPDNField, self).__init__(**kwargs)
|
||||
self.validators.append(validate_ldap_dn)
|
||||
|
||||
def run_validation(self, data=empty):
|
||||
value = super(LDAPDNField, self).run_validation(data)
|
||||
# django-auth-ldap expects DN fields (like AUTH_LDAP_REQUIRE_GROUP)
|
||||
# to be either a valid string or ``None`` (not an empty string)
|
||||
return None if value == '' else value
|
||||
|
||||
|
||||
class LDAPDNWithUserField(fields.CharField):
|
||||
|
||||
@@ -160,6 +166,12 @@ class LDAPDNWithUserField(fields.CharField):
|
||||
super(LDAPDNWithUserField, self).__init__(**kwargs)
|
||||
self.validators.append(validate_ldap_dn_with_user)
|
||||
|
||||
def run_validation(self, data=empty):
|
||||
value = super(LDAPDNWithUserField, self).run_validation(data)
|
||||
# django-auth-ldap expects DN fields (like AUTH_LDAP_USER_DN_TEMPLATE)
|
||||
# to be either a valid string or ``None`` (not an empty string)
|
||||
return None if value == '' else value
|
||||
|
||||
|
||||
class LDAPFilterField(fields.CharField):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user