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)
 | 
			
		||||
        return is_valid or is_valid is None
 | 
			
		||||
 | 
			
		||||
    def pre_check(self, username):
 | 
			
		||||
    def pre_check(self, username, password):
 | 
			
		||||
        if not settings.AUTH_LDAP:
 | 
			
		||||
            return False
 | 
			
		||||
        logger.info('Authentication LDAP backend')
 | 
			
		||||
        if not username:
 | 
			
		||||
            logger.info('Authenticate failed: username is None')
 | 
			
		||||
            return False
 | 
			
		||||
        if not password:
 | 
			
		||||
            logger.info('Authenticate failed: password is None')
 | 
			
		||||
            return False
 | 
			
		||||
        if settings.AUTH_LDAP_USER_LOGIN_ONLY_IN_USERS:
 | 
			
		||||
            user_model = self.get_user_model()
 | 
			
		||||
            exist = user_model.objects.filter(username=username).exists()
 | 
			
		||||
| 
						 | 
				
			
			@ -44,7 +47,7 @@ class LDAPAuthorizationBackend(LDAPBackend):
 | 
			
		|||
        return True
 | 
			
		||||
 | 
			
		||||
    def authenticate(self, request=None, username=None, password=None, **kwargs):
 | 
			
		||||
        match = self.pre_check(username)
 | 
			
		||||
        match = self.pre_check(username, password)
 | 
			
		||||
        if not match:
 | 
			
		||||
            return None
 | 
			
		||||
        ldap_user = LDAPUser(self, username=username.strip(), request=request)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue