Hermes CI Fix
115a0ec755
fix(security): 4端点补跨租户鉴权 — 实体1会话读实体2数据(200)→403 (cma-cross-entity-endpoints-auth-20260914)
背景(项目Bot 补充复验 §四#2):以下 4 个只读端点未做会话账套鉴权,
用 entity=1(酣客) 会话 token + 显式 entity 参数可读到 entity=2(博海) 数据(HTTP 200):
- GET /data-quality/governance-check?entity_id=2 → 200 score=88(对照 entity1=72)
- GET /products/matrix?entity_id=2 → 200
- GET /alerts/risk-matrix?entity=bohai → 200 博海风险矩阵
- GET /action-plans/coso-checklist?entity=bohai → 200 博海 COSO total_score=55
另:risk-matrix / coso-checklist 在非法实体值下静默回落酣客数据,UI 标签与数据不一致。
改动:
1. deps.py 新增统一防护入口 assert_entity_scope / assert_entity_slug_scope /
get_session_entity / resolve_session_slug(文案对齐 get_entity_id:无权访问企业 entity_id=X(当前账套: Y))
2. governance-check / products/matrix:entity_id 须等于会话账套,否则 403;
缺省按会话账套(governance-check 原缺省 0=全部 → 登录态下按账套收敛)
3. risk-matrix / coso-checklist:entity 须等于会话账套,否则 403;
非法值 → 400 显式报错(不再静默回落酣客)
4. P3:POST /auth/switch-entity 加 DEPRECATED 注释(前端已无调用,保留不删)
5. 测试:tests/test_security_multitenant.py 新增 TestCrossEntityEndpointAuth 15 例
(跨实体 403 / 同实体 200 / 缺省按账套 / 非法显式报错 / 参照端点行为不变)
验证:pytest tests/ -q → 951 passed(10 项失败为改动前既有基线,已 stash 对照确认);
真实后端冒烟 19/19 PASS(entity=1 会话 4 端点跨实体全 403)。
2026-09-14 11:19:05 +08:00
..
2026-05-28 17:32:22 +08:00
2026-09-14 11:19:05 +08:00
2026-09-07 10:22:24 +08:00
2026-08-31 09:07:54 +08:00
2026-09-10 09:56:50 +08:00
2026-09-14 11:19:05 +08:00
2026-05-28 17:32:22 +08:00
2026-07-29 18:25:08 +08:00
2026-09-12 10:07:20 +08:00
2026-09-14 11:19:05 +08:00
2026-08-23 18:20:29 +08:00
2026-09-13 00:37:10 +08:00
2026-09-13 00:37:10 +08:00
2026-08-28 00:31:31 +08:00
2026-09-07 10:22:24 +08:00
2026-09-03 18:08:27 +08:00
2026-08-11 11:29:39 +08:00
2026-07-12 17:46:08 +08:00
2026-09-07 11:01:56 +08:00
2026-08-28 18:03:47 +08:00
2026-09-11 17:13:07 +08:00
2026-09-06 16:57:03 +08:00
2026-09-03 01:34:13 +08:00
2026-09-07 10:22:24 +08:00
2026-07-12 17:46:08 +08:00
2026-09-08 15:57:47 +08:00
2026-08-26 07:51:39 +08:00
2026-09-14 11:19:05 +08:00
2026-09-08 11:19:38 +08:00
2026-08-28 18:03:47 +08:00
2026-09-13 00:37:10 +08:00
2026-07-22 12:58:04 +08:00
2026-07-19 10:07:46 +08:00
2026-08-23 18:20:29 +08:00
2026-08-11 11:29:39 +08:00
2026-09-03 23:09:58 +08:00
2026-09-03 23:00:15 +08:00
2026-08-27 15:51:19 +08:00
2026-08-21 16:28:23 +08:00
2026-09-11 17:25:24 +08:00
2026-07-22 18:22:48 +08:00
2026-09-08 20:24:44 +08:00
2026-05-28 17:32:22 +08:00
2026-08-26 23:45:20 +08:00
2026-09-11 19:33:52 +08:00
2026-08-27 12:50:30 +08:00
2026-08-27 10:59:56 +08:00
2026-05-28 17:32:22 +08:00
2026-05-28 17:32:22 +08:00
2026-08-26 22:38:37 +08:00
2026-09-14 11:19:05 +08:00
2026-08-31 10:14:22 +08:00
2026-07-12 17:46:08 +08:00
2026-07-21 23:41:40 +08:00
2026-08-11 11:32:30 +08:00
2026-08-10 23:40:31 +08:00
2026-08-07 17:42:26 +08:00
2026-09-11 17:27:12 +08:00
2026-05-28 17:32:22 +08:00
2026-08-28 18:03:47 +08:00
2026-08-30 19:16:19 +08:00
2026-09-08 20:11:59 +08:00
2026-08-28 18:03:47 +08:00