feat: add django user center auth integration
This commit is contained in:
@@ -137,6 +137,34 @@ http://127.0.0.1:5173
|
||||
| `LLM_REASON_MODEL` | Reason 测试模型 |
|
||||
| `LLM_MOCK_ENABLED` | 是否强制 mock |
|
||||
| `LLM_FALLBACK_TO_MOCK` | 真实模型失败时是否回退 mock |
|
||||
| `AUTH_VALIDATE_ENABLED` | 是否启用 Django 用户中心鉴权 |
|
||||
| `AUTH_USER_ME_URL` | Django 当前用户接口,例如 `http://192.168.2.76:8000/api/user/users/me/` |
|
||||
| `AUTH_TIMEOUT_SECONDS` | 调用用户中心超时时间 |
|
||||
| `AUTH_CACHE_TTL_SECONDS` | 用户信息短期缓存时间 |
|
||||
| `AUTH_ALLOW_DEMO_USER_ID` | 外部鉴权开启时是否允许 `X-User-Id` Demo 兜底 |
|
||||
|
||||
## Django 用户中心联调
|
||||
|
||||
正式联调时,前端进入医疗问诊 Agent 后先调用:
|
||||
|
||||
```text
|
||||
GET /api/v1/auth/me
|
||||
```
|
||||
|
||||
前端需要携带宿主系统登录态:
|
||||
|
||||
```http
|
||||
Authorization: Bearer <token>
|
||||
X-Entry-Scene: mac_vue_dev
|
||||
```
|
||||
|
||||
如果宿主系统使用 Cookie 登录,则前端需要开启 `withCredentials`,后端会把 Cookie 转发到:
|
||||
|
||||
```text
|
||||
http://192.168.2.76:8000/api/user/users/me/
|
||||
```
|
||||
|
||||
FastAPI 会从 Django 返回值中提取 `user_id`,后续病例训练、会话、评价和历史记录都按该 `user_id` 隔离。`X-User-Id` 只作为本地 Demo 兼容方式。
|
||||
|
||||
## 验证命令
|
||||
|
||||
|
||||
Reference in New Issue
Block a user