Skip to content

fix(aurora): adopt rc.22 stateless Bearer access-token auth (login outage) - #69

Merged
Jaykebc1 merged 1 commit into
devfrom
fix/aurora-bearer-auth
Jul 29, 2026
Merged

Jaykebc1 merged 1 commit into
devfrom
fix/aurora-bearer-auth

Conversation

@Jaykebc1

Copy link
Copy Markdown
Collaborator

AI 辅助生成(Claude Code)。生产阻断修复——续接 #68。

问题

rc.22 的 QuantumNous#6329 把 dashboard 的 session cookie 换成无状态 Bearer access-token + refresh cookie,后端现在只认 Authorization: Bearer,无 cookie 回退。aurora 仍用 cookie 鉴权,所以登录后每个请求都未鉴权 → 登不进/登录态不保持。(#68 只修好了 2FA 的 flow_token,是登录链路的前半段;这个 PR 修后半段。)

修复(照上游 web/ 方案移植,纯前端,仅改 aurora/)

  • auth-store:保存 accessToken/accessExpiresAt/session + setBundle/reset。
  • lib/auth-session.ts(新):单飞刷新(POST /api/user/auth/refresh,专用无拦截器 client 防递归)、启动时从 refresh cookie 引导恢复、clearAuthentication;瞬时错误(5xx/429/网络)不强制登出。
  • lib/api.ts:请求拦截器仅在持有 dashboard token 且请求无显式 Authorization 时注入 Bearer(不误伤 relay/API-key 请求);响应拦截器 401 时单飞刷新 + 重试一次,失败则清态跳登录;SSE/playground 的 getCommonHeaders 也带 Bearer。
  • 登录捕获:密码/2FA(保留 flow_token)/passkey/OAuth/微信 全部捕获 bundle。
  • __root beforeLoad await 引导,刷新页面时守卫能看到恢复的会话。

验证

  • 后端 session JSON 字段与前端 bundle 解析器逐一核对匹配。
  • aurora build + typecheck 通过(6 既有告警,无新增)。
  • 鉴权逻辑经审核:防递归、单飞、防循环、不误伤 API-key、瞬时错误不误登出。

规模

10 文件(1 新)。

Users could not stay logged in after rc.22: QuantumNous#6329 replaced the dashboard
session cookie with a stateless Bearer access-token + httpOnly refresh
cookie, and the backend now authenticates dashboard requests ONLY via
'Authorization: Bearer <access_token>' (no cookie fallback). Aurora still
authenticated by cookie, so every post-login request was unauthenticated.

Port the upstream web/ scheme into aurora:
- auth-store: hold accessToken/accessExpiresAt/session + setBundle/reset.
- lib/auth-session.ts (new): single-flight refresh via /api/user/auth/refresh
  on a dedicated interceptor-free client (no recursion), app-boot bootstrap
  from the refresh cookie, and clearAuthentication. Transient (5xx/429/network)
  errors don't force sign-out.
- lib/api.ts: request interceptor injects Bearer only when we hold a dashboard
  token and the request has no explicit Authorization (relay/API-key calls
  untouched); response interceptor does single-flight refresh + one retry on
  401, else clears state and redirects to /sign-in. getCommonHeaders (SSE/
  playground) also carries the Bearer token.
- Capture the login bundle on every path: password, 2FA (keeps flow_token),
  passkey, OAuth, WeChat.
- __root beforeLoad awaits bootstrapAuthentication so guards see the restored
  session on reload.

Backend session JSON verified to match the frontend bundle parser. aurora
build + typecheck clean (6 pre-existing warnings, no new).
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.

1 participant