mirror of https://github.com/veops/cmdb.git
fix(api): ldap authentication
This commit is contained in:
parent
2d2fb6e1d6
commit
fe22e363b4
|
@ -59,6 +59,7 @@ class ErrFormat(CommonErrFormat):
|
|||
email_send_timeout = "邮件发送超时"
|
||||
|
||||
common_data_not_found = "ID {} 找不到记录"
|
||||
common_data_already_existed = "{} 已存在"
|
||||
notice_platform_existed = "{} 已存在"
|
||||
notice_not_existed = "{} 配置项不存在"
|
||||
notice_please_config_messenger_first = "请先配置 messenger"
|
||||
|
@ -74,4 +75,3 @@ class ErrFormat(CommonErrFormat):
|
|||
ldap_test_unknown_error = "LDAP测试未知错误: {}"
|
||||
common_data_not_support_auth_type = "通用数据不支持auth类型: {}"
|
||||
ldap_test_username_required = "LDAP测试用户名必填"
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ from api.models.acl import User
|
|||
|
||||
|
||||
def authenticate_with_ldap(username, password):
|
||||
config = AuthenticateDataCRUD(AuthenticateType.CAS).get()
|
||||
config = AuthenticateDataCRUD(AuthenticateType.LDAP).get()
|
||||
|
||||
server = Server(config.get('LDAP').get('ldap_server'), get_info=ALL, connect_timeout=3)
|
||||
if '@' in username:
|
||||
|
|
|
@ -39,7 +39,7 @@ class LoginView(APIView):
|
|||
password = request.values.get("password")
|
||||
_role = None
|
||||
config = AuthenticateDataCRUD(AuthenticateType.LDAP).get()
|
||||
if config.get('LDAP', {}).get('enabled'):
|
||||
if config.get('LDAP', {}).get('enabled') or config.get('LDAP', {}).get('enable'):
|
||||
from api.lib.perm.authentication.ldap import authenticate_with_ldap
|
||||
user, authenticated = authenticate_with_ldap(username, password)
|
||||
else:
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
from flask import abort, request
|
||||
|
||||
from api.lib.common_setting.common_data import AuthenticateDataCRUD
|
||||
from api.lib.common_setting.const import TestType
|
||||
from api.lib.common_setting.resp_format import ErrFormat
|
||||
from api.lib.perm.acl.acl import role_required
|
||||
from api.resource import APIView
|
||||
from api.lib.common_setting.common_data import AuthenticateDataCRUD
|
||||
from api.lib.common_setting.resp_format import ErrFormat
|
||||
|
||||
prefix = '/auth_config'
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
<a-space>
|
||||
<a-button :loading="loading" type="primary" @click="handleSave">保存</a-button>
|
||||
<template v-if="item.value === 'LDAP'">
|
||||
<a-button :loading="loading" ghost type="primary" @click="handleTest('connect')">测试链接</a-button>
|
||||
<a-button :loading="loading" ghost type="primary" @click="handleTest('connect')">测试连接</a-button>
|
||||
<a-button :loading="loading" ghost type="primary" @click="handleTest('login')">测试登录</a-button>
|
||||
</template>
|
||||
<a-button :loading="loading" @click="handleReset">重置</a-button>
|
||||
|
|
Loading…
Reference in New Issue