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": "連線失敗"
}
}