-
Notifications
You must be signed in to change notification settings - Fork 362
Feature/ldap authentication #552
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
xuebkgithub
wants to merge
11
commits into
Wei-Shaw:main
Choose a base branch
from
xuebkgithub:feature/ldap-authentication
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Feature/ldap authentication #552
xuebkgithub
wants to merge
11
commits into
Wei-Shaw:main
from
xuebkgithub:feature/ldap-authentication
+10,751
−260
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
实现完整的 LDAP 认证系统,支持企业用户通过 LDAP 服务器登录。 - 新增 ldap_configs 表存储 LDAP 服务器配置 - 新增 ldap_users 表关联 LDAP 用户与本地用户 - 使用 Ent ORM 生成完整的 CRUD 代码 - LdapService: 实现 LDAP 连接、用户搜索、密码验证 - 支持 AES-256-GCM 加密存储 LDAP 密码 - 支持从环境变量自动加载配置 - 自动创建本地用户并关联 LDAP 账号 - POST /api/v1/auth/ldap/login: LDAP 登录接口 - 集成 TOTP 2FA 验证 - 返回标准 JWT token - LdapConfigRepository: LDAP 配置数据访问 - LdapUserRepository: LDAP 用户关联数据访问 - 新增 /auth/ldap 独立登录页面 - 支持用户名密码认证 - 完整的错误处理和加载状态 - 添加中英文 LDAP 相关翻译 - 支持动态语言切换 - 根据 ldap_enabled 配置显示/隐藏 LDAP 入口 - 添加"使用 LDAP 登录"按钮 - 防止用户名枚举攻击(统一错误消息) - LDAP 登录强制执行 TOTP 2FA - 敏感信息日志脱敏 - 密码加密存储 - 支持环境变量配置(优先级最高) - 应用启动时自动加载环境变量到数据库 - 公共设置 API 返回 ldap_enabled 状态 - 使用 Wire 完成依赖注入 - 在 provideCleanup 中初始化 LDAP 配置 - 所有服务正确注册到 ProviderSet - 更新 docker-compose-test.yml 支持 LDAP 测试 - 添加数据库迁移脚本 影响范围: 认证系统、用户管理、系统设置
合并远程 main 分支的最新更改,并修复 LDAP 功能集成后的测试和代码质量问题。 主要内容: 1. 远程 main 分支合并(来自 51572b5): - feat(admin): CRS 同步预览和账号选择功能 - feat(service): Digest 会话存储支持 - feat(antigravity): Antigravity 平台改进 - test: 新增多个服务测试用例 - chore: 版本更新和依赖更新 2. LDAP 测试修复: - 添加 LdapConfigRepository 的测试桩实现 - 修复 NewSettingService 函数签名变更导致的测试编译错误 - 修复 ldap.go 中 conn.Close() 未检查错误返回值的问题 3. 代码格式化: - 格式化 LDAP 相关文件,修复 gofmt 警告 - 修复 SettingService 结构体字段对齐格式 - 修复文件末尾缺少换行符问题 冲突解决: - backend/internal/service/wire.go: 保留 NewLdapService 和 NewDigestSessionStore 本地保留功能: - feat(auth): LDAP 认证功能集成 影响范围: - 所有单元测试现在可以正常编译和运行 - 通过 errcheck 和 gofmt 代码质量检查 - 不影响运行时行为
后端改动: - 支持 LDAP 用户名变更时自动更新本地用户记录(users.username 和 ldap_users.ldap_username) - 添加空邮箱验证,拒绝没有 mail 或 userPrincipalName 属性的 LDAP 用户 - 添加多用户搜索结果检测,防止 LDAP 过滤器配置错误 - 实现并发冲突重试机制(最多 3 次,指数退避) - 新增 GetByEmailWithUser 和 UpdateUsernameAndDN repository 方法 - 新增单元测试和集成测试(ldap_test.go, ldap_user_repo_integration_test.go) 前端改动: - 集成 Turnstile 验证组件到 LDAP 登录页面 - 集成 2FA 模态框,支持 TOTP 验证流程 - 更新 API 调用,支持 Turnstile token 和 2FA 临时 token - 添加相关国际化文本(中英文) 测试环境: - 添加 OpenLDAP 服务到 docker-compose-test.yml - 创建 LDAP 测试用户配置文件(ldap-test-users.ldif) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
问题描述: - 用户点击 2FA 模态框的关闭按钮或背景遮罩时,模态框无法关闭 - 原因是 TotpLoginModal 组件缺少 v-model 双向绑定实现 修复内容: - TotpLoginModal.vue: - 添加 show prop 接收父组件状态 - 添加 update:show emit 实现双向绑定 - 模板添加 v-if="show" 控制模态框显示 - 添加 handleCancel 函数同时发出两个事件 - 背景遮罩支持点击关闭 - LoginView.vue: - 修改 TotpLoginModal 使用方式,从 v-if 改为 v-model:show 测试: - Docker 镜像重新构建成功 - 所有容器运行正常(健康状态) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- 在 TotpService 中添加 LDAP 用户检查逻辑 - LDAP 用户设置 2FA 时跳过密码验证步骤 - 调整依赖注入以支持 LDAP 用户仓库 - 添加 TOTP_ENCRYPTION_KEY 到测试环境配置 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- 添加 userRepoStubWithUpdate 类型支持 Update 方法 - 修复测试中 userRepo.Update 调用导致的 panic - 添加 .pnpm-store 到 .gitignore Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- 升级 axios 从 1.6.2 到 1.13.5 - 修复 DoS via __proto__ 漏洞 - 更新 pnpm-lock.yaml Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1. 修复 LDAP 登录 401 被拦截器误判为 token 过期 - 将 /auth/ldap/login 添加到 auth 白名单 - 在跳转逻辑中添加 isAuthEndpoint 检查,避免 auth endpoint 返回 401 时跳转 2. 修复 TotpLoginModal 关闭后状态不重置 - 添加 watch 监听 show prop - 在模态框关闭时自动重置 code/error/verifying 状态 3. 修复 LDAP 页面"返回邮箱登录"路由错误 - 将 /auth/login 改为正确的 /login 路由 4. 修复登录页 LDAP 入口文案硬编码 - 将硬编码的"或"和"使用 LDAP 登录"改为 i18n key - 添加对应的中英文翻译 5. 删除未被引用的 ldap-test-users.ldif 文件 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- 为 ParseGatewayRequest 添加 protocol 参数 - 恢复缺失的辅助函数(needForceCacheBilling, sleepFailoverDelay, sleepAntigravitySingleAccountBackoff)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
feat(auth): 集成 LDAP 认证功能
实现完整的 LDAP 认证系统,支持企业用户通过 LDAP 服务器登录。
后端实现
数据模型
核心服务
API 端点
Repository 层
前端实现
登录页面
国际化
主登录页面集成
安全增强
配置管理
依赖注入
测试环境
影响范围: 认证系统、用户管理、系统设置