Skip to content

T-34: 企业 LDAP 开发者登录(复用外部身份链路) - #349

Closed
SpaceCao wants to merge 1 commit into
higress-group:mainfrom
SpaceCao:feat/ldap-login
Closed

SpaceCao wants to merge 1 commit into
higress-group:mainfrom
SpaceCao:feat/ldap-login

Conversation

@SpaceCao

Copy link
Copy Markdown

背景

T-34:为 himarket 开发者门户接入企业 LDAP(AD)登录,让内网员工用域账号直接登录,省去单独注册。

设计要点

  • 复用现有外部身份链路:DeveloperExternalIdentity(provider+subject 唯一约束)、getExternalDeveloper / createExternalDeveloper 一套流程直接复用,零新建表。
  • JNDI 实现:用 javax.naming.directory 走 bind + search,零外部依赖(不引 Spring LDAP)。
  • DN 解析两路:userDnPattern 直拼 或 userSearchBase + userSearchFilter 由管理员 DN 检索(RFC4515 转义用户名防注入)。
  • 配置驱动、默认可休眠:LdapConfig.enabled() 未配置时 LdapService 直接返回未配置,不影响原有账密 / OAuth2 登录。

改动范围(侵入性评估)

  • 新增 6 个文件:LdapClient、LdapConfig、LdapService/LdapServiceImpl、单测 LdapServiceImplTest,及 DeveloperAuthType.LDAP 枚举值。
  • 原生文件改动仅 3 处共 +24 行、0 删除:DeveloperController(+LDAP 登录端点,@PublicAccess)、PortalSettingConfig(+ldap 字段)、DeveloperAuthType(+LDAP)。
  • 未触碰任何既有认证 / 数据表结构。

测试

  • LdapServiceImplTest:5 用例(已有开发者 / 新建开发者 / 绑定失败 / 未配置 / 检索模式),BUILD SUCCESS。
  • 通过 Connect 函数式接口注入 mock DirContext,不依赖真实 LDAP 服务器。

待上游 review 后补充(非阻塞)

  • portal 配置后台填充 LdapConfig(对接公司 AD 10.2.7.31:389)。
  • 部署 210 做真实 LDAP 联调。
  • 前端登录页「LDAP 登录」Tab(依据 LdapService.isConfigured() 显隐)。

安全

  • 用户名经 RFC4515 转义,防 LDAP 注入。
  • 仅 bind/search,不缓存密码,失败按拒绝处理。

…ntity flow)

- LdapClient: JNDI bind + search, RFC4515 filter escaping, injectable Connect for tests
- LdapConfig + DeveloperAuthType.LDAP + PortalSettingConfig.ldap
- LdapService/LdapServiceImpl: resolve DN (pattern or admin-search), bind verify,
  find-or-create developer via existing external-identity flow, issue token
- DeveloperController POST /developers/ldap/login
- LdapServiceImplTest: 5 cases green (existing/new developer, bind fail, unconfigured, search mode)
@SpaceCao SpaceCao closed this Sep 29, 2026
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


00055624 seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@SpaceCao

Copy link
Copy Markdown
Author

更新:前端 LDAP 登录 Tab 已追加(commit 938151c)

  • 新增 GET /developers/ldap/configured(@PublicAccess)返回 {configured},供登录页在未登录时判断显隐。
  • 开发者门户登录页(himarket-frontend)加 antd Tabs:「账号密码 / LDAP 登录」,仅当 LDAP 已配置才显示;两模式共用用户名/密码表单,按 tab 切到 /developers/ldap/login。
  • i18n(zh/en)補 tabPassword / tabLdap。
  • 后端 ./mvnw compile 已通过;前端 npm install + 类型检查待补(本机依赖缺失,合并前请跑一次 npm run build)。

剩余非阻塞:①portal 后台填 LdapConfig 连公司 AD ②部署 210 真 LDAP 联调。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants