Uh oh!
There was an error while loading. Please reload this page.
feat(usercenter): M1 loginByProvider 统一流程 + OAuth state/cookie 硬化 - #44
Merged
Merged
Conversation
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 例外。
longsizhuoforce-pushed
the
feat/user-identities-m1
branch
from
July 19, 2026 09:54
f299eba to
7e32449Compare
This was referenced Jul 19, 2026
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 freeto 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.
RFC #42 / ADR-001 第二阶段。基于 M0(PR #43),合并前需先合 #43。
loginByProvider(
loginByGithub委托至此)M0 只建表不改行为;M1 让登录开始维护 identity。设计遵循 ADR 的双写期语义:
{provider}_{id}用户名主查(github =github_{id},与历史逐字一致),M3 才翻转到 identity 主查。对现有 8 个loginByGithub测试零逻辑扰动。user_identities;缺行惰性补齐(自愈),兜住 M0-M1 窗口内注册、启动回填尚未覆盖的账号。OAuth state/cookie 硬化(INV-007,修登录 CSRF)
Review 指出登录 CSRF 现状就存在、该在 M1 修:
render种ih_oauth_statecookie(httpOnly + SameSite=Lax + Secure 随 https)。callback在换 token 之前校验 URLstate== cookie,缺失/不匹配即拒(error=oauth_state),不给伪造 state 触发登录的机会,也不白打 GitHub。loginByProvider。新增 INV-007 进 SECURITY.md(INV-006 已被限流占用,按流水规则顺延);含"callback 不得信任 state 中用户身份"的完整理由,M2 绑定流程复用同一防线。
验证
username = github_{github_id},0 例外——M1 用户名主查不会漏查建重复号;0 个"前缀对但缺 id"。🤖 Generated with Claude Code
https://claude.ai/code/session_01RtSNVtrEkCsFVHrbt4Zjgi