mirror of https://github.com/jumpserver/jumpserver
[Update] 修改LDAP认证逻辑,密码为空时认证失败
parent
57155c2469
commit
1c9be184fd
|
@ -27,13 +27,16 @@ class LDAPAuthorizationBackend(LDAPBackend):
|
||||||
is_valid = getattr(user, 'is_valid', None)
|
is_valid = getattr(user, 'is_valid', None)
|
||||||
return is_valid or is_valid is None
|
return is_valid or is_valid is None
|
||||||
|
|
||||||
def pre_check(self, username):
|
def pre_check(self, username, password):
|
||||||
if not settings.AUTH_LDAP:
|
if not settings.AUTH_LDAP:
|
||||||
return False
|
return False
|
||||||
logger.info('Authentication LDAP backend')
|
logger.info('Authentication LDAP backend')
|
||||||
if not username:
|
if not username:
|
||||||
logger.info('Authenticate failed: username is None')
|
logger.info('Authenticate failed: username is None')
|
||||||
return False
|
return False
|
||||||
|
if not password:
|
||||||
|
logger.info('Authenticate failed: password is None')
|
||||||
|
return False
|
||||||
if settings.AUTH_LDAP_USER_LOGIN_ONLY_IN_USERS:
|
if settings.AUTH_LDAP_USER_LOGIN_ONLY_IN_USERS:
|
||||||
user_model = self.get_user_model()
|
user_model = self.get_user_model()
|
||||||
exist = user_model.objects.filter(username=username).exists()
|
exist = user_model.objects.filter(username=username).exists()
|
||||||
|
@ -44,7 +47,7 @@ class LDAPAuthorizationBackend(LDAPBackend):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def authenticate(self, request=None, username=None, password=None, **kwargs):
|
def authenticate(self, request=None, username=None, password=None, **kwargs):
|
||||||
match = self.pre_check(username)
|
match = self.pre_check(username, password)
|
||||||
if not match:
|
if not match:
|
||||||
return None
|
return None
|
||||||
ldap_user = LDAPUser(self, username=username.strip(), request=request)
|
ldap_user = LDAPUser(self, username=username.strip(), request=request)
|
||||||
|
|
Loading…
Reference in New Issue