HXOPS 打开带 token 的地址时,前端只把令牌交给后端,后端向 Casdoor userinfo 校验。D20 接受该实例上任意仍然有效的访问令牌。 Co-authored-by: Cursor <cursoragent@cursor.com>
3.1 KiB
3.1 KiB
Task Context Pack
Task Goal
M02 用 Casdoor 做身份和三个粗角色。密码登录、会话、角色收口、登录页和地址令牌登录已经实现。D20 已确认地址令牌不核对签发应用。用户已确认完成,状态为 DONE_LOCAL。
Knowledge Posture
- Mode: standard
- Maturity: L1
Current Slice Or Group
收尾。地址令牌登录已由用户确认做法并实现。不开始下一个业务模块。
Gate Policy
- Recommended: strict
- Selected: balanced
- finalApprovalRequired: true
- Policy Notes: 认证是 high-risk。O11 已由 D20 确认。标 DONE_LOCAL 仍要用户点头。
Requirement Source
.task/2026-11-17/m02-auth/requirement.md
Implementation Source
.task/2026-11-17/m02-auth/implementation-plan.md。地址令牌是其后按用户指令追加的入口,不在原切片正文里。
Involved Modules Or Areas
services/watchman 的 watchman.auth 与 /auth 路由;web/apps/console 的登录壳。
Loaded Rules
standards://api/api-envelope?version=1.1.0standards://security/red-line?version=1.1.0standards://engineering/code-comments?version=1.1.1- D14、D19、O10、O11
Loaded Docs
docs/tasks/M02.mddocs/runbook.md的登录节docs/decisions.md的 D19、O10、O11.task/2026-11-17/m02-auth/reviews/reviewer-m02-token-login.md
Allowed Modification Scope
services/watchman/src/watchman/auth/services/watchman/src/watchman/api/routes/auth.pyservices/watchman/tests/的登录与会话测试web/apps/console的登录壳、会话和登录 e2edocs/tasks/M02.md、docs/progress.md、docs/runbook.md、docs/decisions.md- 本任务目录下的审查记录和本 context pack
Forbidden Modification Scope
- 不要再给地址令牌加签发应用校验,D20 已经否掉这条
D:\PROJECT\syops的任何写入- 读取、打印或复制
.env.local、访问令牌 - 角色表、用户授权表、密码哈希
- 下一个业务模块
Key Existing Entrypoints
POST /auth/login:密码登录POST /auth/token-login:地址令牌,后端调用 Casdoor userinfoPOST /auth/hxops-entry:签名断言,必须带casdoor_subGET /auth/me、POST /auth/logout
Required Behavior
前端发现 ?token= 后只提交给后端,并从地址栏去掉。后端不把该令牌写入会话、响应或日志。Casdoor 拒绝为 41000,不可用为 503。通过后的会话令牌是 Watchman 自己的。
Validation Commands
uv run pytest services/watchman/tests -qpnpm --filter @watchman/console test:unitpnpm exec playwright test e2e/login.spec.ts(在web/apps/console)
Assumptions
- 会话 8 小时。浏览器同时有 HttpOnly cookie 和 sessionStorage 里的 Watchman access token。
- 真实 Casdoor 只在用户明确要求时调用。测试注入替身。
Risks
- D20:同一 Casdoor 实例上其他应用的有效访问令牌可以换 Watchman 会话。这是已确认行为。
- 地址上的令牌会出现在承接页面的访问日志里。
Stop Conditions
- M02 已 DONE_LOCAL。不开始下一个模块,除非用户另行指定。