Closed
Conversation
added 3 commits
March 3, 2026 10:31
新增完整的 LDAP 认证功能,支持企业级目录服务集成: **后端实现** - 新增 LdapConfig 和 LdapUser 实体及完整 CRUD 操作 - 实现 LDAP 认证服务,支持连接池、TLS、搜索和绑定认证 - 新增插件注册机制,支持动态加载认证插件 - 添加 LDAP 配置和用户仓储层 - 实现 LDAP 认证处理器和路由 **前端实现** - 新增 LDAP 登录插件和视图组件 - 实现 LDAP 配置管理 API 接口 - 集成 LDAP 登录到主登录流程 **数据库** - 新增 ldap_configs 和 ldap_users 表结构 - 支持多租户 LDAP 配置 **测试** - 添加 LDAP 服务单元测试 - 添加 LDAP 用户仓储集成测试 - 更新 docker-compose 测试环境配置 **依赖** - 新增 go-ldap/ldap/v3 库支持 影响范围:52 个文件,新增 10428 行代码
修复 TestFindOrCreateUser_ConcurrentConflict 测试失败的问题:
问题根因:
- 测试使用的 userRepoStub 的 GetByEmail 方法直接 panic
- 在并发冲突重试场景下,findOrCreateUser 会在每次重试时调用 GetByEmail
- 测试返回的错误类型不正确,无法被识别为约束冲突错误
修复内容:
1. 添加 userRepoStubWithGetByEmail 扩展类型,支持配置 GetByEmail 方法
2. 修改测试 mock,使用新的 stub 类型并配置 GetByEmail 返回预设用户
3. 将简单字符串错误改为 &ent.ConstraintError{},确保重试逻辑能正确识别并发冲突
测试结果:
- TestFindOrCreateUser_ConcurrentConflict 测试通过
- 完整单元测试套件通过
cea13c0 to
73d3060
Compare
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
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 层
前端实现
登录页面
国际化
主登录页面集成
安全增强
配置管理
依赖注入
测试环境
影响范围: 认证系统、用户管理、系统设置