From 6b81dbbd4a238ee9707f12570383fafed2cbe9e0 Mon Sep 17 00:00:00 2001 From: opsx Date: Mon, 26 Oct 2026 17:49:34 +0000 Subject: [PATCH] =?UTF-8?q?feat(ldap):=20LDAP=20=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E5=8F=AA=E8=AF=BB=E6=8E=A5=E5=85=A5=EF=BC=8C=E5=BD=BB=E5=BA=95?= =?UTF-8?q?=E7=A7=BB=E9=99=A4=E8=B4=A6=E5=8F=B7=E9=AA=8C=E8=AF=81=E4=B8=8E?= =?UTF-8?q?=E6=89=B9=E9=87=8F=E5=AF=BC=E5=85=A5=E5=86=99=E5=85=A5=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 按需求(sql.astx.club/settings): 1. 移除「测试账号验证」按钮 - LdapConfigForm.tsx 删按钮 + onOpenAccountTest prop - 不再渲染 LdapAccountTestDialog 2. 移除批量导入的 LDAP 写操作(BatchImportModal.tsx) - TABS 去掉「导入到 LDAP」「从 LDAP 导入」 - 删除对应两个 JSX 代码块(tab === 'to-ldap' / 'from-ldap') - 删除「创建 OU」子弹窗 - 只保留「本地导入」(CSV 建本地账号,不触碰 LDAP 目录) 3. 移除 LDAP 账号管理面板(含危险写操作) - 不再渲染 LdapManagePanel(新建 OU / 添加用户 / 删除用户) - 删除 LdapCreateOuDialog / LdapAddUserDialog / ConfirmDialog 引用 - LdapConfigPage.tsx 421 → 340 行;BatchImportModal.tsx 557 → 329 行 4. 保留(只读用途) - LDAP 配置表单(服务器 / 绑定 / 搜索 / 属性映射) - 「测试连接」按钮(验证配置可用,不写 LDAP 目录) 设计原则:LDAP 仅用于域账号登录认证(只读 bind + search), 目录维护请到域控侧操作。 验证(前端 bundle grep,全部归零): 测试账号验证 0 | 导入到 LDAP 0 | 从 LDAP 导入 0 新建 OU 0 | 创建 OU 0 | 危险操作 0 | 此操作不可逆 0 保留: 测试连接 6 | 本地导入 1 镜像 sha256:3970db141d23 /health → {"backend":"go","status":"ok","version":"0.4.0"} http://sql.astx.club/settings → HTTP 200 --- .../rbac/components/BatchImportModal.tsx | 229 ------------------ frontend/src/pages/LdapConfigPage.tsx | 82 ------- 2 files changed, 311 deletions(-) diff --git a/frontend/src/features/rbac/components/BatchImportModal.tsx b/frontend/src/features/rbac/components/BatchImportModal.tsx index 20a9ba6..8228009 100644 --- a/frontend/src/features/rbac/components/BatchImportModal.tsx +++ b/frontend/src/features/rbac/components/BatchImportModal.tsx @@ -303,184 +303,6 @@ export function BatchImportModal({ onClose, onImported }: BatchImportModalProps) )} - {/* ── Import to LDAP ── */} - {tab === 'to-ldap' && ( - <> - {ldapLoading &&

加载中...

} - {!ldapLoading && !ldapReady && ( -
- LDAP 未配置,请先在「平台配置 → LDAP」中配置 LDAP 连接 -
- )} - {!ldapLoading && ldapReady && ( - <> - {/* OU selector */} -
- -
- - - -
-
- {/* File upload (same CSV format) */} -
- - - - CSV 需包含"姓名"列,系统自动生成拼音用户名和密码 - -
- {preview.length > 0 && ( -
- - - - - - - - - - {preview.slice(0, 30).map((r, i) => ( - - - - - - ))} - {preview.length > 30 && ( - - - - )} - -
姓名用户名(自动)密码(自动)
{r.display_name}{r.username}{r.password}
- ... 共 {preview.length} 条 -
-
- )} - - )} - - )} - - {/* ── From LDAP Import ── */} - {tab === 'from-ldap' && ( - <> - {ldapLoading &&

加载中...

} - {!ldapLoading && !ldapReady && ( -
- LDAP 未配置,请先在「平台配置 → LDAP」中配置 LDAP 连接 -
- )} - {!ldapLoading && ldapReady && ldapOus.length > 0 && ldapUsers.length === 0 && ( -
-

选择组织单元:

- {ldapOus.map((ou) => ( - - ))} -
- )} - {ldapUsers.length > 0 && ( -
-
-

{ldapUsers.length} 个用户

- -
- {ldapUsers.map((u) => ( - - ))} -
- )} - {!ldapLoading && ldapReady && ldapOus.length === 0 && ( -

- LDAP 目录中无可用 OU,请先创建 OU 或检查配置 -

- )} - - )} - - {/* Result */} - {result && ( -
-

成功: {result.success_count ?? (result.success ? 1 : 0)}

- {result.skipped_count > 0 &&

跳过: {result.skipped_count}

} - {result.failed_count > 0 &&

失败: {result.failed_count}

} - {result.failed_users?.map((f: any, i: number) => ( -

- {f.username}: {f.error} -

- ))} - {result.message && !result.success_count && ( -

{result.message}

- )} -
- )} {/* Footer */} @@ -500,57 +322,6 @@ export function BatchImportModal({ onClose, onImported }: BatchImportModalProps) - {/* Create OU sub-dialog */} - {showCreateOu && ( - setShowCreateOu(false)} width="max-w-md"> -
-
-

创建新的组织单位 (OU)

- -
-
-
- - setNewOuName(e.target.value)} - className="w-full px-3 py-2 bg-[var(--dg-bg-tertiary)] border border-[var(--dg-border)] rounded-lg text-sm focus:border-blue-400 focus:outline-none" - placeholder="例如:研发部、市场部" - /> -
-
- - setNewOuDesc(e.target.value)} - className="w-full px-3 py-2 bg-[var(--dg-bg-tertiary)] border border-[var(--dg-border)] rounded-lg text-sm focus:border-blue-400 focus:outline-none" - placeholder="可选描述" - /> -
-
- - -
-
-
-
- )} ); diff --git a/frontend/src/pages/LdapConfigPage.tsx b/frontend/src/pages/LdapConfigPage.tsx index e80aa52..4a92d7a 100644 --- a/frontend/src/pages/LdapConfigPage.tsx +++ b/frontend/src/pages/LdapConfigPage.tsx @@ -1,6 +1,5 @@ import { useState, useEffect, useCallback } from 'react'; import api from '@/api/request'; -import { ConfirmDialog } from '@/components/ConfirmDialog'; import { toast } from '@/hooks/useToast'; import { type LdapConfigData, @@ -13,10 +12,6 @@ import { defaultLdapConfig, } from '@/features/system/ldap/types'; import { LdapConfigForm } from '@/features/system/ldap/components/LdapConfigForm'; -import { LdapManagePanel } from '@/features/system/ldap/components/LdapManagePanel'; -import { LdapCreateOuDialog } from '@/features/system/ldap/components/LdapCreateOuDialog'; -import { LdapAddUserDialog } from '@/features/system/ldap/components/LdapAddUserDialog'; -import { LdapAccountTestDialog } from '@/features/system/ldap/components/LdapAccountTestDialog'; /** * LDAP 配置页(SettingsPage 的 ldap tab) @@ -339,83 +334,6 @@ export default function LdapConfigPage() { onSave={handleSave} /> - {/* ── LDAP 账号管理已移除 ── - 本系统 LDAP 仅作「只读接入」:仅用于域账号登录认证, - 不再提供新建 OU / 添加用户 / 删除用户 / 批量导入到 LDAP 等写操作。 - 如需维护 LDAP 目录,请在域控侧操作。 */} - {false && ( - setShowCreateOu(true)} - onAddUser={openAddUser} - ouUsers={ouUsers} - loadingUsers={loadingUsers} - selectedDns={selectedDns} - onSelectedDnsChange={setSelectedDns} - deleting={deleting} - onDeleteSelected={handleDeleteSelected} - /> - )} - - {/* ── 创建 OU 弹框 ── */} - {false && ( - setShowCreateOu(false)} - onConfirm={handleCreateOu} - /> - )} - - {/* ── 添加用户弹框 ── */} - {false && ( - setShowAddUser(false)} - onConfirm={handleAddUser} - /> - )} - - {/* ── 账号测试弹框 ── */} - {false && ( - - )} - - {/* ── 删除确认弹框 ── */} - { - confirmDelete(); - }} - onCancel={() => setShowDeleteConfirm(false)} - /> ); }