Commit 3c2a4703 authored by ibuler's avatar ibuler

[Update] ldap允许空密码

parent 4904aac2
...@@ -16,13 +16,8 @@ class LDAPAuthorizationBackend(LDAPBackend): ...@@ -16,13 +16,8 @@ class LDAPAuthorizationBackend(LDAPBackend):
""" """
def authenticate(self, request=None, username=None, password=None, **kwargs): def authenticate(self, request=None, username=None, password=None, **kwargs):
if password or self.settings.PERMIT_EMPTY_PASSWORD: ldap_user = LDAPUser(self, username=username.strip(), request=request)
ldap_user = LDAPUser(self, username=username.strip(), request=request) user = self.authenticate_ldap_user(ldap_user, password)
user = self.authenticate_ldap_user(ldap_user, password)
else:
logger.debug('Rejecting empty password for {}'.format(username))
user = None
return user return user
def get_user(self, user_id): def get_user(self, user_id):
......
...@@ -96,7 +96,7 @@ class LDAPSettingForm(BaseForm): ...@@ -96,7 +96,7 @@ class LDAPSettingForm(BaseForm):
label=_("LDAP server"), label=_("LDAP server"),
) )
AUTH_LDAP_BIND_DN = forms.CharField( AUTH_LDAP_BIND_DN = forms.CharField(
label=_("Bind DN"), required=False, label=_("Bind DN"),
) )
AUTH_LDAP_BIND_PASSWORD = FormEncryptCharField( AUTH_LDAP_BIND_PASSWORD = FormEncryptCharField(
label=_("Password"), label=_("Password"),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment