@dudousxd/nestjs-authz 0.11.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -87,13 +87,19 @@ that tenant's scoped rows only), and `removeUser(user)` drops all of a user's as
87
87
 
88
88
  Tenant scope: role assignments can be global or per tenant (`assignRole(user, role, { tenantId })`;
89
89
  MikroORM needs `createAuthzEntitySchemas({}, { tenantScoped: true })`, Prisma a `tenantId` column
90
- plus `tenantScoped: true`). Each `AuthzRbacModule` picks the tenant of a check: its `tenant`
91
- resolver (`(user) => id | null | undefined`) first; then, with tenancy on (`tenancy: 'inherit'`
90
+ plus `tenantScoped: true`). Each `AuthzRbacModule` picks the tenant of a check: a scope
91
+ forced by `runInTenantScope` (the dev tools) first; then its `tenant`
92
+ resolver (`(user) => id | null | undefined`); then, with tenancy on (`tenancy: 'inherit'`
92
93
  follows `ContextModule.forRoot({ tenancy: { enabled: true } })`; `false` opts out), the context
93
94
  tenant from `Context.setTenant`; with tenancy off, TypeORM/Drizzle read `Context.tenantId()` and
94
- MikroORM/Prisma check global assignments only. `tenancy: { roles: { owner: 'org_admin' } }` maps
95
- the caller's `tenant.role` to authz roles in that tenant only (context user only). No tenant,
96
- `allTenants` or no request = global assignments only.
95
+ MikroORM/Prisma check global assignments only. With nested tenants, assignments held at every
96
+ level of the active chain the module honours apply (`tenancy.kinds`, else the context's `kinds`;
97
+ `tenancy.family` narrows to one family). `tenancy: { roles: { owner: 'org_admin' } }` maps
98
+ the caller's `tenant.role` at each honoured level to authz roles (context user only). No tenant
99
+ (`tenantless`) or no request = global assignments only, unless `tenancy.required` (default: the
100
+ context's) is set — then a check with no tenant throws `TenantRequiredError` (403,
101
+ `E_TENANT_REQUIRED`). `all`/`system` (`Context.allTenants()` and siblings) stay global even
102
+ when required.
97
103
 
98
104
  ## Core patterns
99
105