feat: 统一登录门户(按角色分流五套工作台)+ 补齐权限覆盖缺口

- tools/portal.py:客户/风控/运营/管理员/投顾五个工作台,走真实登录与真实接口
- 新增 6 个此前从未建过的权限码(promotion:* 4 个 / financial:nl2sql:read / probe:read),
  它们让推广材料与金融 NL2SQL 两条线对所有角色都是 403
- 投顾权限 10 → 25 项:补投资目标创建确认、agent:run、行情、知识检索、客户画像、推广材料
- 运营补 financial:nl2sql:read;create_test_user.py 不再硬编码角色 id(改按 role_code 查库)
- portal 的写请求补 Idempotency-Key 头(漏了会被 AGENT_INPUT_INVALID 拒)
- 新增 tools/check_permission_coverage.py 做权限对账
This commit is contained in:
2026-09-12 15:21:34 +08:00
parent 4c00db5636
commit bfd622b592
6 changed files with 1479 additions and 16 deletions
+22 -1
View File
@@ -71,10 +71,15 @@ ADVISOR_PERMISSIONS: tuple[tuple[int, str, str, str, str], ...] = (
(9043, "product-governance:sync", "product-governance", "sync", "all"),
)
#: 投顾拿哪些 —— 工作流那 10 个;治理类 6 个只给 admin。
#: 投顾拿哪些。2026-09-12 补齐:此前只给了 10 项工作流权限,结果投顾**用不了**
#: 投资目标创建/确认、跑不了 Agent、查不了行情与知识、看不了所服务客户的画像 ——
#: 表现出来就是一片 `AGENT_PERMISSION_DENIED`。下面每一项都对应代码里真实用到的地方。
ADVISOR_GRANTED_CODES: tuple[str, ...] = (
# 投顾工作流(定义在种子的 9020-9034)
"asset-allocation:generate:self",
"investment-goal:read:self",
"investment-goal:write:self", # 新建投资目标
"investment-goal:confirm:self", # 与客户确认目标
"investment-goal:review",
"investment-goal:publish",
"portfolio-analysis:read:self",
@@ -83,6 +88,22 @@ ADVISOR_GRANTED_CODES: tuple[str, ...] = (
"product-recommendation:generate:self",
"product-recommendation:review",
"product-recommendation:publish",
# 平台通用:投顾同样要跑 Agent、查行情、检索知识、看所服务客户的画像
"agent:run",
"suitability:read",
"fund:quote:read",
"knowledge:query",
"knowledge:reference:read",
"memory:read:customer",
"conversation:create",
"conversation:close",
"conversation:feedback",
# 推广材料(`promotion_material_service.py:164` 专门判 `advisor`)
"promotion:read",
"promotion:write",
"promotion:deliver",
# 金融数据(`financial_nl2sql_service.py` 的角色白名单含 advisor)
"financial:nl2sql:read",
)
#: admin 角色 id(`seed_test_rbac.py` 建的)。