[Update] ldap允许空密码

pull/2420/head^2
ibuler 2019-02-21 16:37:36 +08:00
parent 4904aac2df
commit 3c2a4703bc
2 changed files with 3 additions and 8 deletions

View File

@ -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):

View File

@ -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"),