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": "Gerenciamento de Usuários",
"ldap": "LDAP",
"avatar": "Avatar",
"id": "ID",
"email": "E-mail",
@@ -434,5 +435,27 @@
"tag_error_create": "Falha ao criar tag. Por favor, tente novamente.",
"tag_error_update": "Falha ao atualizar tag. Por favor, tente novamente.",
"tag_error_delete": "Falha ao excluir tag. Por favor, tente novamente."
},
"Ldap": {
"ldap_settings": "Configurações de LDAP",
"ldap_description": "Autenticar usuários em um diretório LDAP.",
"enable_ldap": "Ativar LDAP",
"enable_ldap_desc": "Permitir que os usuários entrem com suas credenciais do diretório.",
"server_url": "URL do servidor",
"bind_dn": "Bind DN",
"bind_credentials": "Senha de Bind",
"bind_credentials_placeholder": "Deixe em branco para manter a senha atual",
"search_base": "Base de busca",
"search_filter": "Filtro de busca",
"email_attribute": "Atributo de e-mail",
"username_attribute": "Atributo de nome de usuário",
"save": "Salvar",
"saved": "Configurações de LDAP salvas",
"save_error": "Falha ao salvar as configurações de LDAP",
"test_connection": "Testar conexão",
"test_username": "Usuário de teste",
"test_password": "Senha de teste",
"test_success": "Conexão bem-sucedida",
"test_failed": "Falha na conexão"
}
}