fix(auth): token 登录将令牌放入 Authorization: Bearer 头
token 换登录调上游 getTokenInfo 时参数传错:原来发静态头 Authorization: Bearer admin + 令牌放 access_token cookie。上游实际 从 Authorization: Bearer <token> 头读取令牌。 - 鉴权头改为 "Bearer "+前端传入 token,删除 access_token cookie - service_authorization 配置项弃用(保留兼容,不再参与请求) - 新增回归测试 test_token_login_upstream_call.py - 同步更新 AUTH_LOGIN.md / CLAUDE.md / config.yaml 注释 / login_config 文档 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
247ff86f2f
commit
e1e9be8daa
7 files changed
+112
-20
No files matched your search
@@ -90,14 +90,13 @@ Content-Type: application/json
|
||||
POST /api/v1/auth/login/token?token=<上游access_token>
|
||||
```
|
||||
|
||||
后端据此向 `token_info_url` 发起(与下方 curl 对齐):
|
||||
后端据此向 `token_info_url` 发起(与下方 curl 对齐):**前端传入的 token 直接拼成 `Authorization: Bearer <token>` 头**,上游从该头读取令牌(不再用 cookie,也不再用静态 `service_authorization`)。
|
||||
|
||||
```bash
|
||||
curl 'https://ch1.b.uat.4.cn/consumer/login/getTokenInfo' \
|
||||
-X POST \
|
||||
-H 'authorization: Bearer admin' \
|
||||
-H 'content-type: application/x-www-form-urlencoded' \
|
||||
-H 'cookie: access_token=<上游access_token>'
|
||||
-H 'authorization: Bearer <上游access_token>' \
|
||||
-H 'content-type: application/x-www-form-urlencoded'
|
||||
```
|
||||
|
||||
上游返回示例:
|
||||
@@ -131,7 +130,7 @@ curl 'https://ch1.b.uat.4.cn/consumer/login/getTokenInfo' \
|
||||
|
||||
- 两个端点都在 `auth_middleware._PUBLIC_EXACT_PATHS` 白名单内(免会话鉴权,自身完成鉴权)。
|
||||
- 口令门是**最低限度**的共享密钥防护,适合内网/受控环境;非每用户独立密码。
|
||||
- token 换登录信任上游 `getTokenInfo` 的鉴权结论,务必保证 `service_authorization` 与 `token_info_url` 配置正确且走内网/HTTPS。
|
||||
- token 换登录信任上游 `getTokenInfo` 的鉴权结论,务必保证 `token_info_url` 配置正确且走内网/HTTPS。前端传入的 token 会直接作为 `Authorization: Bearer <token>` 发给上游,因此该 token 必须来自可信入口。(`service_authorization` 配置项已不再参与请求,保留仅为兼容,后续可移除。)
|
||||
|
||||
## 相关代码
|
||||
|
||||
|
||||
Reference in new issue
Block a user