mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-16 15:28:38 +00:00
[Update] LDAP 登录认证添加配置项:只有在用户列表中的用户会被允许认证
This commit is contained in:
@@ -32,6 +32,13 @@ class LDAPAuthorizationBackend(LDAPBackend):
|
||||
if not username:
|
||||
logger.info('Authenticate failed: username is None')
|
||||
return None
|
||||
if settings.AUTH_LDAP_USER_LOGIN_ONLY_IN_USERS:
|
||||
user_model = self.get_user_model()
|
||||
exist = user_model.objects.filter(username=username).exists()
|
||||
if not exist:
|
||||
msg = 'Authentication failed: user ({}) is not in the user list'
|
||||
logger.info(msg.format(username))
|
||||
return None
|
||||
ldap_user = LDAPUser(self, username=username.strip(), request=request)
|
||||
user = self.authenticate_ldap_user(ldap_user, password)
|
||||
logger.info('Authenticate user: {}'.format(user))
|
||||
|
Reference in New Issue
Block a user