Repository navigation
Conversation
后端一截先行:迁移补 display_name/disabled_at,auth 服务加管理员建号、 改显示名/角色/禁用、重置口令,Verify/Login 拒绝已禁用账号;禁用动作在同一事务 里吊销该用户全部未撤销 token(会话与 PAT),下一跳即失效。最后一个启用中的 管理员不可降级/禁用。 路由 /api/users* 三重闸:Bearer(allowPAT=false) + RequireAdmin;开放注册保持 关闭。契约补进 openapi.yaml,configuration.md 新增「哪些端点强制 Bearer」表。 前端用户管理页、生成物同步与真实浏览器 E2E 尚未做,看板保持执行中。
后端最小用户管理已在上一提交落地;本次补齐验收中缺失的三块: - 越权与未认证拆码:新增 CodeForbidden=20201,非管理员调 /api/users、 PAT 调 tokens/users 均返回 20201;RequireAdmin 与 Bearer(allowPAT=false) 同步切换。补「仅存禁用管理员时注册仍关闭」的回归测试。 - 前端用户管理页:分页列表 + 建号 + 角色切换 + 禁用/启用 + 重置口令, 仅管理员可见(菜单入口与页面双重收敛,非管理员直接访问显示 403)。 加极小 authSession 外部 store:登录/退出后顶部菜单立刻重算(会话 token 仍只存内存,刷新即失)。 - 文档口径:api.md 补 20201 与用户管理端点节,overview/configuration 写明 「资源端点仍匿名、登录不等于全站受保护」。 验证:go test -race ./... 全绿;pnpm build:check 全绿(956 tests); 在真实浏览器(Qoder 内置浏览器,bsk 扩展未连接)跑通管理员注册→建号→ 普通用户登录→非管理员 /users 被拒(20201/403)→禁用→被禁用者登录被拒 (20200)→重置口令旧口令失效新口令可登录,并在页面内验证最后管理员 不可自禁用(20400) 与 PAT 调 /api/users 返回 20201。
This was referenced Oct 24, 2026
…20202 + migration 00013->00014)
Contributor
Author
评审轮 E2E 证据(PR #232 / issue #202 最小用户管理)门禁(全绿)
真实 HTTP E2E(curl,临时 PG 全新库 + 单进程 app)
结论:门禁 + E2E 全绿,合并入 master。 |
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.
做了什么
issue #202 的后端端点在上一提交已落地(4 个
/api/users*端点、disabled_at迁移、最后管理员守卫、禁用即吊销 token)。本次补齐验收里仍缺的三块:1. 越权码 20201(与未认证 20200 拆开)
response.CodeForbidden = 20201,新增response.Forbidden()。RequireAdmin:已登录但非管理员 → 20201;Bearer(allowPAT=false):PAT 调 tokens/users → 20201。未登录仍是 20200。POST /api/auth/register仍被拒(禁用用disabled_at而非软删,若改成软删会重新打开注册、任何人都能抢管理员)。2. 前端「用户管理」页
frontend/src/pages/Users.tsx:服务端分页 + 关键字、建号、角色切换、禁用/启用、重置口令。/users显示 403 结果页;自己的角色选择与禁用按钮不出现。lib/authSession.ts外部 store:登录/退出后 App 菜单立即重算(会话 token 仍只存内存、刷新即失,没有引入持久化)。3. 文档口径
docs/developer-guide/api.md:错误码表拆 20200/20201,新增「11.1 用户管理」端点节。docs/getting-started/overview.md:「现在有什么」与 Phase C 条目按实际能力重写。docs/user-guide/configuration.md:鉴权现状表补/api/users*(上一提交已加)并写明两个错误码语义。怎么做的
RegisterRoute泛型路由 +Bearer(allowPAT=false)+RequireAdmin三重闸;PUT 遵循「未提供则保留」(指针字段区分省略与显式置零)。UpdateUser在同一事务里写disabled_at并吊销该用户全部未撤销 token;Verify每次请求额外校验disabled_at IS NULL,双保险、无缓存窗口。api/index.ts(与现有 auth/PAT 类型同档)。未提交生成物:make api-gen后端半步会带出与本条无关的历史漂移(AuthUserRole常量重命名、SampleDatasetStatus补齐),前端半步因openapi-typescript@7×typescript@7的ts.factory问题必然失败(仓库已知问题)。api/openapi.yaml已作为契约事实源更新。测试证据
cd backend && go test -race ./...→ 全绿(含新增 auth/middleware 用例)。cd frontend && pnpm build:check→ 全绿,67 files / 956 tests。make serve单进程 :23352,独立 E2E 库,未触碰共享开发库):/users显示「仅管理员可访问」,接口返回 20201;invalid username or password,新口令可登录;/api/users返回 20201。bsk browsers为空),浏览器验证改用 Qoder 内置真实浏览器完成,页面与网络请求均为实跑。未做(保持 issue 边界)
PUT /api/auth/password(issue 里列为「建议」,且涉及撤销其他会话的语义,可另开单)。