@dudousxd/nestjs-authz-prisma 0.6.0 → 0.8.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,70 @@
1
1
  # @dudousxd/nestjs-authz-prisma
2
2
 
3
+ ## 0.8.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#76](https://github.com/DavideCarvalho/nestjs-authz/pull/76) [`d2a9b06`](https://github.com/DavideCarvalho/nestjs-authz/commit/d2a9b06c398b80c68957ae573c1f5bd866a9ff72) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Add MCP dev tools: `AuthzModule` registers `authz_explain_check`, `authz_list_effective_roles` and `authz_list_effective_permissions` in the Aviary dev-tools slot (`Symbol.for('@dudousxd/aviary:dev-tools')`, created when absent). They register without an `authorize`, so the agent dev endpoint's `devTools.authorize` gates them (open outside production, denied in production without it); a hub that cannot gate console-less libs leaves them out. `devTools: { loadSubject, loadResource }` hands checks your models (default: `resolveUser` and `resourceLoaders`); `devTools: false` turns the tools off. New: `gate.explainFor(user, ability, resource?)`, `runInTenantScope(tenantId, fn)`, and `RoleProvider.describeRbac?(user)`, which the RBAC adapters implement; the adapters honour a scope forced by `runInTenantScope` ahead of their `tenant` resolver and the context tenant.
8
+
9
+ - [#76](https://github.com/DavideCarvalho/nestjs-authz/pull/76) [`d2a9b06`](https://github.com/DavideCarvalho/nestjs-authz/commit/d2a9b06c398b80c68957ae573c1f5bd866a9ff72) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - A `schema` option puts the authz tables in their own database schema: a Postgres schema, or a MySQL database. Every statement names it, and `search_path` is never used.
10
+
11
+ - **TypeORM** (Postgres and MySQL): `storeOptions.schema`. Adds `authzEntities({ schema, type, tableNames })` for synchronize/migration-generated setups.
12
+ - **Drizzle** (Postgres): `createAuthzTables({ schema })` / `storeOptions.schema`.
13
+ - **MikroORM** (Postgres and MySQL): `createAuthzEntitySchemas(names, { schema })`. The store reads the schema from the entity metadata and qualifies its raw SQL. On MySQL, the heal narrows MikroORM's diff against the target database's `information_schema`. `authzSchemaSql()` includes the create statement.
14
+ - **Prisma** (Postgres): the `schema` option, for models with `@@schema`. The fast path uses `$queryRawUnsafe` with the schema in the SQL and every value bound.
15
+
16
+ Shared behaviour:
17
+
18
+ - Auto-create makes the schema only when the catalog says it is missing. A failure names the grant needed.
19
+ - On SQLite, a `schema` fails at boot. Prisma refuses it on MySQL and SQLite.
20
+ - Names are validated (a safe identifier, at most 63 characters).
21
+ - Without `schema`, nothing changes.
22
+
23
+ - [#76](https://github.com/DavideCarvalho/nestjs-authz/pull/76) [`d2a9b06`](https://github.com/DavideCarvalho/nestjs-authz/commit/d2a9b06c398b80c68957ae573c1f5bd866a9ff72) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Tenancy for nested tenants, tenant families and required tenants (nestjs-context's chain contract, read structurally, so older contexts keep working):
24
+
25
+ - A role or grant assigned at any level of the active tenant chain applies (a clinic role counts inside its units). `tenancy.kinds` picks the levels, and the context's own `kinds` apply when the module sets none.
26
+ - `tenancy.roles` maps the caller's role at every level of the chain.
27
+ - New `tenancy.family` option.
28
+ - New `tenancy.required` option, defaulting to the context's. A check with no tenant throws `TenantRequiredError` (403, `E_TENANT_REQUIRED`) instead of running in the global scope.
29
+ - Console `authorize` helpers, the MCP dev tools, and the new `runWithoutRequiredTenant(fn)` pass `required: false`.
30
+ - `describeRbac` reports the `tenantChain`.
31
+
32
+ ## 0.7.0
33
+
34
+ ### Minor Changes
35
+
36
+ - Back on the 0.x line. The 1.x and 2.x versions were published by accident: a release-tooling peer cascade bumped this package to a major, not an API decision. 0.7.0 contains everything those versions shipped (console `authorize` support, tenancy, Node 24+ `engines`) with no other change. Upgrade from 1.x/2.x to 0.7.0; those versions are deprecated.
37
+
38
+ ## 2.0.0
39
+
40
+ ### Major Changes
41
+
42
+ - [#74](https://github.com/DavideCarvalho/nestjs-authz/pull/74) [`35421dc`](https://github.com/DavideCarvalho/nestjs-authz/commit/35421dc5b09bd271d5087d26e8536191ef6ba342) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - **Breaking:** require Node.js 24 or newer (`engines.node` is now `>=24`; it was `>=22`, and `>=20` for `-client` and `-react`). CI tests on Node 24 and 26. No API changes: see the Upgrading page in the docs.
43
+
44
+ ## 1.1.1
45
+
46
+ ### Patch Changes
47
+
48
+ - [#73](https://github.com/DavideCarvalho/nestjs-authz/pull/73) [`9fd6787`](https://github.com/DavideCarvalho/nestjs-authz/commit/9fd6787307361b8552236a833d969fa041a46bca) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Fix the `$queryRaw` permission fast path: it is now called on the client instead of detached from it. A real `PrismaClient` threw on the unbound call, so every permission check silently fell back to the three-query path.
49
+
50
+ ## 1.1.0
51
+
52
+ ### Minor Changes
53
+
54
+ - [#72](https://github.com/DavideCarvalho/nestjs-authz/pull/72) [`58a5d72`](https://github.com/DavideCarvalho/nestjs-authz/commit/58a5d72d2964a7cfae9cbfe8506526c8518ba30a) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Tenancy for the RBAC modules, following the `@dudousxd/nestjs-context` tenancy switch.
55
+
56
+ - New `tenancy` option (`'inherit' | false | { enabled?, kinds?, nullRows?, roles? }`, default `'inherit'`). With context tenancy on, permission and role checks are scoped to the request's tenant from `Context.setTenant`. A request with no tenant, inside `Context.allTenants()`, or outside a request sees global assignments only. `kinds` limits the tenant kinds this module honours. With tenancy off nothing changes.
57
+ - `tenancy.roles` maps the caller's role inside the tenant (`tenant.role`) to authz roles that apply in that tenant only, e.g. `{ owner: 'org_admin' }`.
58
+ - New `tenant` resolver option, `(user) => tenantId | null | undefined`: an explicit tenant that wins over the context.
59
+ - MikroORM and Prisma can now store tenant-scoped role assignments like Drizzle and TypeORM: `assignRole`, `removeRole` and `setUserRoles` take `{ tenantId }`, and the read methods take a tenant scope. MikroORM: build the entities with `createAuthzEntitySchemas({}, { tenantScoped: true })`. Prisma: add `tenantId String @default("")` to `UserRole` and its `@@id`, then pass `tenantScoped: true`. Without that, every assignment stays global.
60
+
61
+ ## 1.0.0
62
+
63
+ ### Patch Changes
64
+
65
+ - Updated dependencies [[`750a6b3`](https://github.com/DavideCarvalho/nestjs-authz/commit/750a6b3f80deea3803dec8df5f9f8cf67a046ac1)]:
66
+ - @dudousxd/nestjs-authz@0.10.0
67
+
3
68
  ## 0.6.0
4
69
 
5
70
  ### Minor Changes
package/README.md CHANGED
@@ -185,10 +185,70 @@ await store.listRoleAssignments({ user: { type: 'user', id: 7 } });
185
185
  await store.removeUser({ type: 'user', id: 7 });
186
186
  ```
187
187
 
188
- This adapter has no tenant-scoped assignments, so every row has `tenantId: null`:
189
- `listRoleAssignments({ tenantId: null })` lists everything and a tenant id string matches
190
- nothing. Without `roleSources: true` every row is `'manual'`, so filtering by another
191
- `source` matches nothing.
188
+ `tenantId` filters: omitted = every tenant, `null` = global assignments only, a string = that
189
+ tenant's scoped assignments only. Without `tenantScoped: true` (below) every row has
190
+ `tenantId: null`, so a tenant id string matches nothing. Without `roleSources: true` every row
191
+ is `'manual'`, so filtering by another `source` matches nothing.
192
+
193
+ ## Tenant-scoped roles
194
+
195
+ Tenant-scoped assignments are opt-in. Add the column to `UserRole` and its `@@id`, then run
196
+ `prisma migrate dev` (existing rows get `''`, a global assignment):
197
+
198
+ ```prisma
199
+ model UserRole {
200
+ userType String
201
+ userId String
202
+ roleId String
203
+ tenantId String @default("")
204
+
205
+ @@id([userType, userId, roleId, tenantId])
206
+ @@index([userType, userId])
207
+ @@map("authz_user_role")
208
+ }
209
+ ```
210
+
211
+ Then turn it on: `new PrismaAuthzStore(prisma, { tenantScoped: true })`, or
212
+ `AuthzRbacModule.forRoot({ client: prisma, tenantScoped: true })`.
213
+
214
+ ```ts
215
+ await store.assignRole(user, 'editor', { tenantId: 'acme' }); // only inside acme
216
+ await store.assignRole(user, 'viewer'); // everywhere
217
+ await store.getRolesForUser(user, { tenantId: 'acme' }); // ['editor', 'viewer']
218
+ await store.getRolesForUser(user); // ['viewer']
219
+ ```
220
+
221
+ `removeRole` and `setUserRoles` take the same `{ tenantId }` (omitted = the global
222
+ assignments). Without `tenantScoped`, every assignment is global and reads ignore the tenant.
223
+ `assignRole` and `setUserRoles` with a `tenantId` throw; `removeRole` with one does nothing,
224
+ since there is no tenant assignment to remove.
225
+
226
+ ## Tenancy
227
+
228
+ The RBAC module reads the tenant only when tenancy is on: turn it on with
229
+ `ContextModule.forRoot({ tenancy: { enabled: true } })` in `@dudousxd/nestjs-context`. Checks
230
+ are then scoped to the request's tenant from `Context.setTenant(...)`.
231
+ A request with no tenant, or inside `Context.allTenants()`, sees global assignments only.
232
+
233
+ ```ts
234
+ AuthzRbacModule.forRoot({
235
+ client: prisma,
236
+ tenantScoped: true,
237
+ tenancy: {
238
+ kinds: ['organization'], // optional: tenant kinds this module honours
239
+ roles: { owner: 'org_admin', member: 'org_member' }, // optional: tenant.role → authz roles in that tenant
240
+ },
241
+ tenant: (user) => (user as { orgId?: string }).orgId, // optional: an explicit tenant wins over the context
242
+ });
243
+ ```
244
+
245
+ `tenancy` defaults to `'inherit'` (follow the context switch); `false` keeps this module out.
246
+ Roles mapped with `roles` apply only inside that tenant and only to the context's current user.
247
+ The `tenant` resolver returns a tenant id, `null` for the global scope, or `undefined` to fall
248
+ back to the context.
249
+
250
+ With tenancy on and without `tenantScoped`, every assignment is global, so only `roles` and the
251
+ `tenant` resolver change what a check sees.
192
252
 
193
253
  ## License
194
254
 
@@ -2,6 +2,7 @@ import type { UserRef } from '@dudousxd/nestjs-authz/store-kit';
2
2
  import { type DynamicModule } from '@nestjs/common';
3
3
  import { PrismaAuthzStore } from './prisma-authz.store.js';
4
4
  import { type PrismaAuthzClientLike } from './prisma-client.js';
5
+ import { type AuthzTenancyOption, type TenantResolver } from './tenancy.js';
5
6
  /** Injection token holding the {@link PrismaAuthzStore} the RBAC module manages. */
6
7
  export declare const AUTHZ_RBAC_STORE: unique symbol;
7
8
  /** Injection token holding the resolved {@link AuthzRbacModuleOptions}. */
@@ -30,11 +31,32 @@ export interface AuthzRbacModuleOptions {
30
31
  * `source` column on `UserRole`. Only used when the module builds the store from `client`.
31
32
  */
32
33
  roleSources?: boolean;
34
+ /**
35
+ * Tenant-scoped role assignments (see {@link PrismaAuthzStoreOptions.tenantScoped}); requires
36
+ * the `tenantId` column on `UserRole`. Only used when the module builds the store from `client`.
37
+ */
38
+ tenantScoped?: boolean;
39
+ /**
40
+ * The Postgres schema of the authz models (`@@schema`), see {@link PrismaAuthzStoreOptions.schema}.
41
+ * Only used when the module builds the store from `client`.
42
+ */
43
+ schema?: string;
33
44
  /**
34
45
  * Derive a {@link UserRef} from the Gate's current user. Defaults to
35
46
  * {@link defaultUserRefMapper} (`{ type, id }` or `{ id }`).
36
47
  */
37
48
  userRefFrom?: UserRefMapper;
49
+ /**
50
+ * Tenancy, from `@dudousxd/nestjs-context`. `'inherit'` (default) follows `ContextModule`'s
51
+ * `tenancy.enabled`; with it on, checks are scoped to the context tenant. The object form adds
52
+ * `kinds` and `roles` (map the caller's `tenant.role` to authz roles in that tenant).
53
+ */
54
+ tenancy?: AuthzTenancyOption;
55
+ /**
56
+ * Explicit tenant for a check, from the user being checked. Wins over the context: return a
57
+ * tenant id, `null` for the global scope, or `undefined` to fall back to the context.
58
+ */
59
+ tenant?: TenantResolver;
38
60
  }
39
61
  export interface AuthzRbacModuleAsyncOptions {
40
62
  imports?: unknown[];
@@ -1 +1 @@
1
- {"version":3,"file":"authz-rbac.module.d.ts","sourceRoot":"","sources":["../src/authz-rbac.module.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EACL,KAAK,aAAa,EAQnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAiB,KAAK,qBAAqB,EAAE,MAAM,oBAAoB,CAAC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qBACa,eAAe;IAC1B,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,sBAAsB,GAAG,aAAa;IAa9D,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,2BAA2B,GAAG,aAAa;IAsBxE,OAAO,CAAC,MAAM,CAAC,eAAe;CAS/B"}
@@ -11,9 +11,11 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
11
11
  return function (target, key) { decorator(target, key, paramIndex); }
12
12
  };
13
13
  var AuthzRbacModule_1;
14
- import { PERMISSION_PROVIDER, ROLE_PROVIDER, } from '@dudousxd/nestjs-authz';
14
+ import { CONTEXT_ACCESSOR, PERMISSION_PROVIDER, ROLE_PROVIDER, } from '@dudousxd/nestjs-authz';
15
15
  import { Inject, Injectable, Module, Optional, } from '@nestjs/common';
16
+ import { ModuleRef } from '@nestjs/core';
16
17
  import { PrismaAuthzStore } from './prisma-authz.store.js';
18
+ import { acrossScopes, inAnyScope, rbacTenant, } from './tenancy.js';
17
19
  /** Injection token holding the {@link PrismaAuthzStore} the RBAC module manages. */
18
20
  export const AUTHZ_RBAC_STORE = Symbol.for('@dudousxd/nestjs-authz-prisma:store');
19
21
  /** Injection token holding the resolved {@link AuthzRbacModuleOptions}. */
@@ -35,7 +37,11 @@ function resolveStore(options) {
35
37
  if (options.store)
36
38
  return options.store;
37
39
  if (options.client) {
38
- return new PrismaAuthzStore(options.client, options.roleSources ? { roleSources: true } : {});
40
+ return new PrismaAuthzStore(options.client, {
41
+ ...(options.roleSources ? { roleSources: true } : {}),
42
+ ...(options.tenantScoped ? { tenantScoped: true } : {}),
43
+ ...(options.schema !== undefined ? { schema: options.schema } : {}),
44
+ });
39
45
  }
40
46
  throw new Error('AuthzRbacModule (prisma): provide either `store` or `client` in the options.');
41
47
  }
@@ -46,13 +52,27 @@ function resolveStore(options) {
46
52
  */
47
53
  let RbacPermissionProvider = class RbacPermissionProvider {
48
54
  options;
55
+ context;
56
+ moduleRef;
49
57
  // `getPermissions` lists every grant `hasPermission` can find, for any resource.
50
58
  exhaustivePermissions = true;
51
59
  store;
52
- constructor(options) {
60
+ contextCache = { resolved: false, value: undefined };
61
+ constructor(options, context, moduleRef) {
53
62
  this.options = options;
63
+ this.context = context;
64
+ this.moduleRef = moduleRef;
54
65
  this.store = resolveStore(options);
55
66
  }
67
+ tenant(user, ref) {
68
+ return rbacTenant(this.options, user, ref, this.context, this.moduleRef, this.contextCache, false);
69
+ }
70
+ /** The permissions `tenancy.roles` grants through the caller's role in the tenant. */
71
+ async tenantRolePermissions(roles) {
72
+ if (roles.length === 0)
73
+ return [];
74
+ return Object.values(await this.store.getRolePermissions(roles)).flat();
75
+ }
56
76
  // The core `PermissionProvider` interface passes an optional `resource` (3rd
57
77
  // arg); it is intentionally ignored here. RBAC grants are model-less,
58
78
  // named-ability grants (the Laravel/spatie `Gate::before` grant), so the
@@ -62,7 +82,11 @@ let RbacPermissionProvider = class RbacPermissionProvider {
62
82
  const ref = map(user);
63
83
  if (ref === undefined)
64
84
  return undefined;
65
- return this.store.userHasPermission(ref, permission);
85
+ const tenant = this.tenant(user, ref);
86
+ if (await inAnyScope(tenant, (scope) => this.store.userHasPermission(ref, permission, scope))) {
87
+ return true;
88
+ }
89
+ return (await this.tenantRolePermissions(tenant.roles)).includes(permission);
66
90
  }
67
91
  // Expose the user's full granted permission set so the core can apply
68
92
  // Laravel/spatie-style wildcard matching (a granted `posts.*` satisfies a check
@@ -72,13 +96,20 @@ let RbacPermissionProvider = class RbacPermissionProvider {
72
96
  const ref = map(user);
73
97
  if (ref === undefined)
74
98
  return undefined;
75
- return this.store.getPermissionsForUser(ref);
99
+ const tenant = this.tenant(user, ref);
100
+ const own = await acrossScopes(tenant, (scope) => this.store.getPermissionsForUser(ref, scope));
101
+ if (tenant.roles.length === 0)
102
+ return own;
103
+ return [...new Set([...own, ...(await this.tenantRolePermissions(tenant.roles))])];
76
104
  }
77
105
  };
78
106
  RbacPermissionProvider = __decorate([
79
107
  Injectable(),
80
108
  __param(0, Inject(AUTHZ_RBAC_OPTIONS)),
81
- __metadata("design:paramtypes", [Object])
109
+ __param(1, Optional()),
110
+ __param(1, Inject(CONTEXT_ACCESSOR)),
111
+ __param(2, Optional()),
112
+ __metadata("design:paramtypes", [Object, Object, ModuleRef])
82
113
  ], RbacPermissionProvider);
83
114
  /**
84
115
  * The RBAC {@link RoleProvider} the Gate consults (via the shared {@link ROLE_PROVIDER}
@@ -88,23 +119,62 @@ RbacPermissionProvider = __decorate([
88
119
  */
89
120
  let RbacRoleProvider = class RbacRoleProvider {
90
121
  options;
122
+ context;
123
+ moduleRef;
91
124
  store;
92
- constructor(options) {
125
+ contextCache = { resolved: false, value: undefined };
126
+ constructor(options, context, moduleRef) {
93
127
  this.options = options;
128
+ this.context = context;
129
+ this.moduleRef = moduleRef;
94
130
  this.store = resolveStore(options);
95
131
  }
132
+ tenant(user, ref) {
133
+ return rbacTenant(this.options, user, ref, this.context, this.moduleRef, this.contextCache, false);
134
+ }
96
135
  async getRoles(user) {
97
136
  const map = this.options.userRefFrom ?? defaultUserRefMapper;
98
137
  const ref = map(user);
99
138
  if (ref === undefined)
100
139
  return undefined;
101
- return this.store.getRolesForUser(ref);
140
+ const tenant = this.tenant(user, ref);
141
+ const own = await acrossScopes(tenant, (scope) => this.store.getRolesForUser(ref, scope));
142
+ return tenant.roles.length === 0 ? own : [...new Set([...own, ...tenant.roles])];
143
+ }
144
+ /**
145
+ * Where the user's roles and permissions come from, for the core's dev tools
146
+ * (`authz_explain_check`): the scope the lookups ran in, store vs `tenancy.roles` roles,
147
+ * each role's permissions, and every permission granted in that scope.
148
+ */
149
+ async describeRbac(user) {
150
+ const map = this.options.userRefFrom ?? defaultUserRefMapper;
151
+ const ref = map(user);
152
+ if (ref === undefined)
153
+ return undefined;
154
+ const tenant = this.tenant(user, ref);
155
+ const [own, permissions] = await Promise.all([
156
+ acrossScopes(tenant, (scope) => this.store.getRolesForUser(ref, scope)),
157
+ acrossScopes(tenant, (scope) => this.store.getPermissionsForUser(ref, scope)),
158
+ ]);
159
+ const roles = [...new Set([...own, ...tenant.roles])];
160
+ const rolePermissions = roles.length === 0 ? {} : await this.store.getRolePermissions(roles);
161
+ const fromTenantRoles = tenant.roles.flatMap((role) => rolePermissions[role] ?? []);
162
+ return {
163
+ tenantId: tenant.scope.tenantId ?? null,
164
+ tenantChain: tenant.scopes.flatMap((scope) => (scope.tenantId ? [scope.tenantId] : [])),
165
+ roles: { store: own, tenant: tenant.roles },
166
+ rolePermissions,
167
+ permissions: [...new Set([...permissions, ...fromTenantRoles])],
168
+ };
102
169
  }
103
170
  };
104
171
  RbacRoleProvider = __decorate([
105
172
  Injectable(),
106
173
  __param(0, Inject(AUTHZ_RBAC_OPTIONS)),
107
- __metadata("design:paramtypes", [Object])
174
+ __param(1, Optional()),
175
+ __param(1, Inject(CONTEXT_ACCESSOR)),
176
+ __param(2, Optional()),
177
+ __metadata("design:paramtypes", [Object, Object, ModuleRef])
108
178
  ], RbacRoleProvider);
109
179
  /**
110
180
  * Runs `ensureSchema` on bootstrap when `autoCreateSchema` is enabled. For Prisma this is
@@ -1 +1 @@
1
- {"version":3,"file":"authz-rbac.module.js","sourceRoot":"","sources":["../src/authz-rbac.module.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,OAAO,EACL,mBAAmB,EAEnB,aAAa,GAEd,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAEL,MAAM,EACN,UAAU,EACV,MAAM,EAEN,QAAQ,GAGT,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAG3D,oFAAoF;AACpF,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,GAAG,CAAC,qCAAqC,CAAC,CAAC;AAClF,2EAA2E;AAC3E,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,GAAG,CAAC,uCAAuC,CAAC,CAAC;AAwCtF,qFAAqF;AACrF,MAAM,UAAU,oBAAoB,CAAC,IAAa;IAChD,I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E,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,sBAAsB,EAAE;YACrE,gBAAgB;YAChB,EAAE,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,gBAAgB,EAAE;YACzD,kBAAkB;SACnB,CAAC;IACJ,CAAC;CACF,CAAA;AA7CY,eAAe;IAD3B,MAAM,CAAC,EAAE,CAAC;GACE,eAAe,CA6C3B"}
package/dist/index.d.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  export { PRISMA_AUTHZ_STORE_OPTIONS, PRISMA_CLIENT, type PrismaAuthzClientLike, type PrismaAuthzStoreOptions, type PrismaModelDelegate, } from './prisma-client.js';
2
- export { PrismaAuthzStore } from './prisma-authz.store.js';
3
- export type { RoleAssignment, RoleAssignmentFilter, RoleSourceOptions, UserAuthz, UserRoleAssignment, } from './prisma-authz.store.js';
2
+ export { GLOBAL_TENANT, PrismaAuthzStore } from './prisma-authz.store.js';
3
+ export type { RoleAssignment, RoleAssignmentFilter, RoleSourceOptions, TenantScope, UserAuthz, UserRoleAssignment, } from './prisma-authz.store.js';
4
4
  export { AUTHZ_RBAC_OPTIONS, AUTHZ_RBAC_STORE, AuthzRbacModule, defaultUserRefMapper, } from './authz-rbac.module.js';
5
5
  export type { AuthzRbacModuleAsyncOptions, AuthzRbacModuleOptions, UserRefMapper, } from './authz-rbac.module.js';
6
+ export type { AuthzTenancyOption, TenantResolver } from './tenancy.js';
6
7
  export type { UserRef, UserRefInput } from '@dudousxd/nestjs-authz/store-kit';
7
8
  export { applyScope, compileScope } from './scope.js';
8
9
  export type { PrismaWhere, ScopeResolver } from './scope.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,aAAa,EACb,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,GACzB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,gBAAgB,EA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AAW,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC"}
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export { PRISMA_AUTHZ_STORE_OPTIONS, PRISMA_CLIENT, } from './prisma-client.js';
2
- export { PrismaAuthzStore } from './prisma-authz.store.js';
2
+ export { GLOBAL_TENANT, PrismaAuthzStore } from './prisma-authz.store.js';
3
3
  export { AUTHZ_RBAC_OPTIONS, AUTHZ_RBAC_STORE, AuthzRbacModule, defaultUserRefMapper, } from './authz-rbac.module.js';
4
4
  export { applyScope, compileScope } from './scope.js';
5
5
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,aAAa,GAId,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAQ3D,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,oBAAoB,GACrB,MAAM,wBAAwB,CAAC;AAOhC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,aAAa,GAId,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAS1E,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,oBAAoB,GACrB,MAAM,wBAAwB,CAAC;AAQhC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC"}
@@ -1,10 +1,23 @@
1
1
  import { type RoleAssignment, type RoleAssignmentFilter, type UserAuthz, type UserRef, type UserRoleAssignment } from '@dudousxd/nestjs-authz/store-kit';
2
2
  import { type PrismaAuthzClientLike, type PrismaAuthzStoreOptions } from './prisma-client.js';
3
3
  export type { RoleAssignment, RoleAssignmentFilter, UserAuthz, UserRoleAssignment };
4
- /** Assignment source for role mutations (default `'manual'`) — see `setUserRoles`. */
5
- export interface RoleSourceOptions {
4
+ /**
5
+ * Optional tenant scope for a query. Omitted → the GLOBAL scope (only global assignments; a
6
+ * tenant-scoped role never leaks into an unscoped check). With a `tenantId`, global assignments
7
+ * AND that tenant's apply. Needs `tenantScoped: true`; without it every assignment is global.
8
+ */
9
+ export interface TenantScope {
10
+ tenantId?: string;
11
+ }
12
+ /**
13
+ * Assignment source (default `'manual'`, needs `roleSources: true`) and tenant (needs
14
+ * `tenantScoped: true`) for role mutations — see `setUserRoles`.
15
+ */
16
+ export interface RoleSourceOptions extends TenantScope {
6
17
  source?: string;
7
18
  }
19
+ /** The tenant id of a GLOBAL role assignment (applies in every tenant). */
20
+ export declare const GLOBAL_TENANT = "";
8
21
  /**
9
22
  * Prisma-backed RBAC store. Receives the app-owned Prisma client via the
10
23
  * {@link PRISMA_CLIENT} DI token — NO internal connection ownership, NO `@prisma/client`
@@ -17,11 +30,19 @@ export declare class PrismaAuthzStore {
17
30
  private readonly client;
18
31
  private readonly options;
19
32
  constructor(client: PrismaAuthzClientLike, options?: PrismaAuthzStoreOptions);
33
+ /** `"schema"."table"` with the `schema` option, else the bare quoted table (as before). */
34
+ private table;
20
35
  /**
21
36
  * The `source` filter/value for an assignment: `{ source }` when per-source assignments are on,
22
37
  * `{}` otherwise (legacy schema without the column) — where a non-default source is an error.
23
38
  */
24
39
  private sourceField;
40
+ /** The `tenantId` value of a written assignment (`{}` without `tenantScoped`). */
41
+ private tenantField;
42
+ /** Assignments visible in a scope: global ones, plus the tenant's own when one is given. */
43
+ private tenantWhere;
44
+ /** The public `tenantId` of a stored row: `null` for a global assignment. */
45
+ private static rowTenant;
25
46
  /**
26
47
  * No-op: Prisma is schema-first / consumer-managed. Declare the RBAC models in your
27
48
  * `schema.prisma` (see {@link PrismaAuthzClientLike}) and apply them with
@@ -68,7 +89,9 @@ export declare class PrismaAuthzStore {
68
89
  assignRole(user: UserRef, roleName: string, opts?: RoleSourceOptions): Promise<void>;
69
90
  /**
70
91
  * Remove a role from a user. No-op if the role or assignment is absent. With `{ source }` only
71
- * that source's assignment goes; without it, the role is removed from every source.
92
+ * that source's assignment goes; without it, the role is removed from every source. With
93
+ * `tenantScoped`, `{ tenantId }` removes the assignment in that tenant and omitting it removes
94
+ * the global one.
72
95
  */
73
96
  removeRole(user: UserRef, roleName: string, opts?: RoleSourceOptions): Promise<void>;
74
97
  /**
@@ -76,18 +99,23 @@ export declare class PrismaAuthzStore {
76
99
  * `roleNames` — e.g. an SSO/SCIM sync calls `setUserRoles(user, mappedRoles, { source: 'sso' })`
77
100
  * on every login; other sources' assignments are untouched. Roles are created by name when
78
101
  * missing. Atomic when the client has `$transaction`. Without `roleSources: true` there is only
79
- * one (implicit manual) source, so this replaces ALL of the user's roles.
102
+ * one (implicit manual) source, so this replaces ALL of the user's roles. With `tenantScoped` it
103
+ * replaces the assignments of one tenant (`{ tenantId }`), or the global ones when omitted.
80
104
  */
81
105
  setUserRoles(user: UserRef, roleNames: readonly string[], opts?: RoleSourceOptions): Promise<void>;
82
- /** Every role assignment of a user, one entry per `(role, source)`. */
83
- getRoleAssignments(user: UserRef): Promise<RoleAssignment[]>;
106
+ /**
107
+ * Every role assignment of a user visible in a tenant scope (global ones always; the tenant's
108
+ * own with `{ tenantId }`), one entry per `(role, source, tenant)`.
109
+ */
110
+ getRoleAssignments(user: UserRef, scope?: TenantScope): Promise<RoleAssignment[]>;
84
111
  /**
85
112
  * Raw role-assignment rows for admin listings — e.g. who holds a role (`{ role: 'admin' }`) or
86
113
  * a user's assignments with their sources (`{ user }`). `role` accepts one name or a list;
87
114
  * `user` and `source` narrow further. Ordered by `(userType, userId, role, source)`.
88
115
  *
89
- * This adapter has no tenant-scoped assignments — every row is global (`tenantId: null`). So
90
- * `tenantId: undefined` or `null` lists everything, and a tenant id string matches nothing.
116
+ * `tenantId`: omitted = no tenant filter; `null` = global assignments only; a string = exactly
117
+ * that tenant's scoped assignments. Without `tenantScoped: true` every row is global
118
+ * (`tenantId: null`), so a tenant id string matches nothing.
91
119
  * Without `roleSources: true` every row is `'manual'`, so another `source` matches nothing.
92
120
  */
93
121
  listRoleAssignments(filter?: RoleAssignmentFilter): Promise<UserRoleAssignment[]>;
@@ -96,8 +124,8 @@ export declare class PrismaAuthzStore {
96
124
  * Roles and permissions are kept. (This adapter has no direct user permissions.)
97
125
  */
98
126
  removeUser(user: UserRef): Promise<void>;
99
- /** The role names a user holds. */
100
- getRolesForUser(user: UserRef): Promise<string[]>;
127
+ /** The role names a user holds, in a tenant scope (see {@link TenantScope}). */
128
+ getRolesForUser(user: UserRef, scope?: TenantScope): Promise<string[]>;
101
129
  /**
102
130
  * The flattened, distinct permission names a user has via their roles.
103
131
  *
@@ -107,12 +135,11 @@ export declare class PrismaAuthzStore {
107
135
  *
108
136
  * Fast path: when the injected client exposes `$queryRaw`, assemble the set in a
109
137
  * SINGLE database round-trip via one JOIN (3 round-trips → 1). On ANY failure
110
- * (missing `$queryRaw`, custom `@@map` table names, non-Postgres identifier
111
- * quoting, etc.) it degrades to {@link getPermissionsViaDelegates}, so correctness
138
+ * (custom `@@map` table names, non-Postgres identifier quoting, etc.) it degrades to {@link getPermissionsViaDelegates}, so correctness
112
139
  * is preserved everywhere and only the common (Postgres + documented schema) case
113
140
  * gets the speedup.
114
141
  */
115
- getPermissionsForUser(user: UserRef): Promise<string[]>;
142
+ getPermissionsForUser(user: UserRef, scope?: TenantScope): Promise<string[]>;
116
143
  /**
117
144
  * The original three-query implementation (userRole → rolePermission → permission),
118
145
  * returning the same deduped permission-name set as {@link getPermissionsForUser}.
@@ -120,9 +147,9 @@ export declare class PrismaAuthzStore {
120
147
  * fast path throws.
121
148
  */
122
149
  private getPermissionsViaDelegates;
123
- /** A user's roles + effective permissions in one shot. */
124
- getUserAuthz(user: UserRef): Promise<UserAuthz>;
125
- /** True when the user holds `permission` through any of their roles. */
126
- userHasPermission(user: UserRef, permission: string): Promise<boolean>;
150
+ /** A user's roles + effective permissions in one shot, in a tenant scope. */
151
+ getUserAuthz(user: UserRef, scope?: TenantScope): Promise<UserAuthz>;
152
+ /** True when the user holds `permission` through any of their roles, in a tenant scope. */
153
+ userHasPermission(user: UserRef, permission: string, scope?: TenantScope): Promise<boolean>;
127
154
  }
128
155
  //# sourceMappingURL=prisma-authz.store.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"prisma-authz.store.d.ts","sourceRoot":"","sources":["../src/prisma-authz.store.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,cAAc,EACnB,KAAK,oBAAoB,EACzB,KAAK,SAAS,EACd,KAAK,OAAO,EACZ,KAAK,kBAAkB,EAIxB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAGL,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAC7B,MAAM,oBAAoB,CAAC;AAI5B,YAAY,EAAE,cAAc,EAAE,oBAAoB,EAAE,SAAS,EAAE,kBAAkB,EAAE,CAAC;AAEpF,sFAAsF;AACtF,MAAM,WAAW,iBAAiB;IAChC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAOD;;;;;;;GAOG;AACH,qBACa,gBAAgB;IAGzB,OAAO,CAAC,QAAQ,CAAC,MAAM;IAGvB,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAHP,MAAM,EAAE,qBAAqB,EAG7B,OAAO,GAAE,uBAA4B;IAGxD;;;OAGG;IACH,OAAO,CAAC,WAAW;IAUnB;;;;;OAKG;IACG,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAMnC,+EAA+E;IACzE,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAgB/C,qFAAqF;IAC/E,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;YAevC,UAAU;YAK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