forked from wangziqi/gongxue-base
test: add rls tenant isolation regression
This commit is contained in:
@@ -92,6 +92,8 @@ Supabase 官方允许前端用 Data API 访问数据,但前提是 RLS、最小
|
||||
- API SQL 必须显式带 `tenant_id`。
|
||||
- 测试必须覆盖跨租户读取、写入、下载、后台权限越权。
|
||||
- `npm run readiness:production:db` 会阻断带 `tenant_id` 但未启用 RLS、没有 policy、或 public policy 未包含 `app.current_tenant_id()` 的表。
|
||||
- `npm run test:rls` 会在本地 smoke seed 后模拟 Supabase `authenticated/anon/platform_admin` JWT claims,动态验证主租户和合作商租户代表性表不会跨租户读写泄露,并验证无 `tenant_id` claim 不能读取租户数据。
|
||||
- `test:rls` 为了模拟 PostgREST 角色会在事务内临时授予 `authenticated/anon` 查询探针权限,所有 grant、写入探针和跨租户插入都会回滚;它验证的是 RLS policy 行为,不代表生产要开放核心业务表直连。
|
||||
- 新增租户表时必须同时提交 migration、RLS policy、API 权限测试或明确说明只允许平台级访问的原因。
|
||||
|
||||
## 前端必须遵守
|
||||
@@ -183,6 +185,7 @@ provider event id 幂等
|
||||
|
||||
- `npm run audit:runtime` 为 0 high/critical 漏洞;Taro 构建工具链 audit 单独跟踪,不能用破坏性降级绕过。
|
||||
- `npm run check:refactor` 通过。
|
||||
- `npm run test:rls` 通过;必须确认主租户、合作商租户、无租户 claim、平台管理员旁路和跨租户写入拒绝都有运行时证据。
|
||||
- `npm run readiness:production` 没有 blocker。
|
||||
- `npm run readiness:production:db` 没有 blocker,尤其是 `db.rls.tenant_tables_enabled`、`db.rls.tenant_tables_policy`、`db.rls.public_tenant_context` 必须通过。
|
||||
- 生产环境启动时默认密钥 fail-fast 生效。
|
||||
|
||||
Reference in New Issue
Block a user