- 稳定性
- 稳定
- 作用域
- 按租户隔离
- 边界
- packages/iam/permissions
RBAC · ABAC
| 资源 | 查看 | 写入 | 删除 | 管理 |
|---|---|---|---|---|
| 项目 | ||||
| 账单 | ||||
| 审计日志 | ||||
| API 密钥 | ||||
| 团队成员 |
由 CASL 驱动 · 服务端校验
使用方式permissions.ts
typescriptpermissions.ts
1import { defineAbility } from "@nebutra/permissions";
2
3const ability = defineAbility((can, cannot, user) => {
4 if (user.role === "admin") can("manage", "all");
5 can("read", "Post", { tenantId: user.tenantId });
6 can("update", "Post", { authorId: user.id });
7 cannot("delete", "Post", { isPublished: true });
8});
9
10ability.can("update", post);