feat: add LDAP authentication settings and toggle

Add an admin-only LDAP configuration UI with an enable toggle and full
sign-in integration.

Backend:
- ldapSettings model + migration (single-row config)
- GET/PUT/test routes under /ldap (admin-gated; bind password masked)
- shared ldapClient with RFC 4515 filter escaping and empty-password guard
- signin tries local auth first, then LDAP when enabled (find-or-create
  local user) so the bootstrap admin is never locked out

Frontend:
- LDAP settings page (Switch + form + test connection) under /admin/ldap
- AdminNav tabs between user management and LDAP
- ldapControl util, types, and Ldap i18n namespace for all 6 locales

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
LittleYellow
2026-06-26 07:20:08 +08:00
parent 02fa631f02
commit 1c977f9266
25 changed files with 992 additions and 19 deletions

View File

@@ -149,6 +149,7 @@
},
"Admin": {
"user_management": "用户管理",
"ldap": "LDAP",
"avatar": "头像",
"id": "ID",
"email": "邮箱",
@@ -434,5 +435,27 @@
"tag_error_create": "标签创建失败,请重试。",
"tag_error_update": "标签更新失败,请重试。",
"tag_error_delete": "标签删除失败,请重试。"
},
"Ldap": {
"ldap_settings": "LDAP 设置",
"ldap_description": "通过 LDAP 目录验证用户身份。",
"enable_ldap": "启用 LDAP",
"enable_ldap_desc": "允许用户使用目录凭据登录。",
"server_url": "服务器地址",
"bind_dn": "绑定 DN",
"bind_credentials": "绑定密码",
"bind_credentials_placeholder": "留空以保留当前密码",
"search_base": "搜索基准",
"search_filter": "搜索过滤器",
"email_attribute": "邮箱属性",
"username_attribute": "用户名属性",
"save": "保存",
"saved": "LDAP 设置已保存",
"save_error": "保存 LDAP 设置失败",
"test_connection": "测试连接",
"test_username": "测试用户名",
"test_password": "测试密码",
"test_success": "连接成功",
"test_failed": "连接失败"
}
}