Skip to content

feat(usercenter): M1 loginByProvider + M2a 解绑/列表(合并进 main) - #47

Merged
longsizhuo merged 2 commits into
mainfrom
feat/identity-m1-m2a
Jul 19, 2026
Merged

feat(usercenter): M1 loginByProvider + M2a 解绑/列表(合并进 main)#47
longsizhuo merged 2 commits into
mainfrom
feat/identity-m1-m2a

Conversation

@longsizhuo

Copy link
Copy Markdown
Member

把 M1 + M2a 干净地补进 main。

背景:#44(M1)的 base 误填成 M0 分支,合进了分支而非 main,导致 M1 从未进主干;
#46(M2a)分支因此与 squash 后的 main 冲突。本 PR 从当前 main cherry-pick M1 与
M2a 两个 commit(M0/review/db-fix 已在 main #43),无冲突,全量 263 测试通过。

  • M1:loginByProvider 统一流程(username 主查 + identity 双写)+ OAuth state/cookie
    硬化(INV-007)
  • M2a:GET/DELETE /api/user-center/identities(解绑锁死防护 + github 解绑清 github_id)

替代 #46(将关闭)。

RFC #42 / ADR-001 第二阶段。
loginByProvider(loginByGithub 委托至此):
- 账号仍按 "{provider}_{id}" 用户名主查(双写期,M3 才翻转到 identity 主查)
- 无论新建/已存在都维护一行 user_identities(identity 双写),缺行惰性补齐,
兜住 M0-M1 窗口回填未覆盖的账号;identity 写失败不阻断登录(同 INV-003 策略)
- github_id 列双写沿用(createUser/updateProfile 已写)
OAuth state/cookie 硬化(INV-007,登录 CSRF):
- render 种 httpOnly + SameSite=Lax 的 ih_oauth_state cookie
- callback 在换 token 前校验 URL state == cookie,缺失/不匹配即拒(error=oauth_state)
- callback 端点保持 github 专用(泛化 AuthRequest 工厂留到 M3 真接第二个 provider)
新增 INV-007 进 SECURITY.md(INV-006 已被限流占用,按流水规则顺延)。
全量 257 测试通过;生产数据核查:51 个 github 账号 username 约定 0 例外。
RFC #42 / ADR-001。绑定新 provider(M2b)走 OAuth 流程另开 PR;本 PR 做查看+解绑,
自包含,闭合 M0 review 的两个发现。
- GET /api/user-center/identities:列出当前用户已绑定身份(不泄漏 provider_user_id)
- DELETE /api/user-center/identities/{provider}:解绑
- 不能解绑最后一种登录方式(防永久锁死;OAuth 随机密码不可靠,保守按剩余身份数判定)
- 解绑 github 同事务清空 github_id 列(否则 schema.sql 启动回填按残留列值静默复活)
- repository 加 deleteByUserIdAndProvider / clearGithubId
全量 263 测试通过(+6:列表/解绑/锁死拦截/未拥有拒绝/清列/匿名 401)。
CopilotAI review requested due to automatic review settings July 19, 2026 12:18

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@longsizhuo
longsizhuo merged commit e607ce9 into mainJul 19, 2026
@longsizhuo
longsizhuo deleted the feat/identity-m1-m2a branch July 19, 2026 12:18
Sign up for freeto 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

@longsizhuo