- access token 是 15 分钟的 JWT,走 Authorization: Bearer;refresh token 7 天,每次换都轮换 - 退出登录、改密码、禁用账号仍然立刻生效:每个请求核对 Redis 会话和库里新加的 user.token_version - 在服务器后台改密码 / 禁用,机房那边登着的也会一起下线(原来两边 Redis 分开,管不到) - WebSocket 握手借子协议带 token;JWT 密钥存在本站 Redis,部署不用加配置 - 去掉 COOKIE_SECURE;上线后所有人要重新登录一次 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4be569d978
commit
793848b06f
31 files changed
+4639
-333
No files matched your search
+8
-4
@@ -95,10 +95,14 @@ shared → ./src/shared
|
||||
|
||||
### HTTP Client
|
||||
|
||||
`utils/api.ts` — Axios instance with interceptors (`baseURL: "/api"`,
|
||||
`withCredentials`). It unwraps both the axios envelope and the backend's
|
||||
`{ data }` envelope, so callers get the payload directly. All API calls proxy
|
||||
through the dev server (see `vite.config.ts`).
|
||||
`utils/api.ts` — Axios instance with interceptors (`baseURL: "/api"`). It unwraps both
|
||||
the axios envelope and the backend's `{ data }` envelope, so callers get the payload
|
||||
directly. All API calls proxy through the dev server (see `vite.config.ts`).
|
||||
|
||||
登录态是 `Authorization: Bearer` 的 access token(15 分钟)+ refresh token,都在
|
||||
localStorage,换 token 的逻辑全在 `utils/auth.ts`。**不走 axios 的请求用 `authFetch`
|
||||
代替裸 `fetch`**,否则不带 token、也不会在 `token-expired` 时换一张重试。
|
||||
WebSocket 的 token 借子协议带(浏览器设不了请求头),见契约 `WS_AUTH_PROTOCOL`。
|
||||
|
||||
### Contract guard (`utils/contract.ts`)
|
||||
|
||||
|
||||
Reference in new issue
Block a user