forked from wangziqi/gongxue-base
feat: add platform admin permissions
This commit is contained in:
@@ -283,6 +283,7 @@ tenant:<tenantId>:theme
|
||||
| 公共题库采纳/同步 | `GET /api/tenant-content/public-question-banks`、`POST /api/tenant-content/public-question-banks/adopt`、`POST /api/tenant-content/public-question-banks/sync`、`GET /api/tenant-content/public-question-banks/conflicts?adoptionId=...`、`POST /api/tenant-content/public-question-banks/conflicts/resolve`、`POST /api/tenant-content/public-question-banks/conflicts/resolve-batch` |
|
||||
| 题库导出 | `POST /api/tenant-content/exports/questions`、`GET /api/tenant-content/exports/jobs` |
|
||||
| 资料/视频运营审计 | `GET /api/tenant-content/media-analytics/summary`、`asset-events`、`video-events` |
|
||||
| 平台权限目录 | `GET /api/platform-admin/permissions` |
|
||||
|
||||
## 资料、PDF 和视频资源契约
|
||||
|
||||
@@ -2600,6 +2601,47 @@ format csv | json
|
||||
|
||||
平台审计告警属于超级管理员后台能力。内部告警由 `apps/worker --job platform-audit-alerts` 根据 `platform_audit_alert_rules` 从平台审计日志生成,外部通知由 `apps/worker --job platform-audit-notifications` 根据 `platform_audit_notification_channels` 入队并发送到 generic、钉钉、飞书或企业微信 webhook。前端不要直接读写 Supabase 表。
|
||||
|
||||
## 平台后台权限
|
||||
|
||||
平台后台不再假设所有 `platform_admin` 都是全权限。Taro 平台后台启动后应先调用:
|
||||
|
||||
```text
|
||||
GET /api/platform-admin/permissions
|
||||
```
|
||||
|
||||
响应结构:
|
||||
|
||||
```json
|
||||
{
|
||||
"item": {
|
||||
"primaryRole": "platform_admin",
|
||||
"permissions": {
|
||||
"platform:tenant:read": true,
|
||||
"platform:billing:read": true
|
||||
},
|
||||
"effective": {
|
||||
"platform:tenant:read": true,
|
||||
"platform:tenant:write": false
|
||||
},
|
||||
"catalog": [
|
||||
{
|
||||
"key": "platform:tenant:read",
|
||||
"group": "tenant",
|
||||
"label": "查看租户"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
前端处理规则:
|
||||
|
||||
- `effective` 只用于隐藏菜单、按钮和表单,不是安全边界。
|
||||
- 真实权限由后端在每个 `/api/platform-admin/*` 接口强制校验;越权会返回 `PLATFORM_PERMISSION_REQUIRED`。
|
||||
- 平台菜单推荐映射:租户中心用 `platform:tenant:read`,创建租户用 `platform:tenant:write`,状态变更用 `platform:tenant:status`,账务资料用 `platform:tenant:billing_profile`,账务中心用 `platform:billing:read/write/payment/dunning`,审计中心用 `platform:audit:read/export/alert/notification`,公共题库用 `platform:question_bank:read/grant`。
|
||||
- `permissions` 里可能出现 `{"*":true}` 或 `platform:billing:*` 这类通配权限,前端只消费后端返回的 `effective`,不要自己重新实现权限匹配规则。
|
||||
- 平台后台 H5 不允许保存 `x-platform-admin-key`;生产必须使用 Supabase Auth access token。
|
||||
|
||||
查询启用规则:
|
||||
|
||||
```text
|
||||
|
||||
Reference in New Issue
Block a user