@dudousxd/nestjs-authz 0.11.0 → 0.13.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,26 @@
1
1
  # @dudousxd/nestjs-authz
2
2
 
3
+ ## 0.13.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#80](https://github.com/DavideCarvalho/nestjs-authz/pull/80) [`30d2e98`](https://github.com/DavideCarvalho/nestjs-authz/commit/30d2e986a7c2adc9b5d8464dc4a419f35e30a6eb) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - `authorizeByRoles({ roles, loginPath })` and `authorizeByPermission(permission, { loginPath })` send a guest to the app's sign-in page instead of the console's bare 401. A page load is redirected to `loginPath?redirect=<page>`, and a console API call answers 401 with that `redirectTo`, which the console follows. A signed-in user without access still gets 403. Set `redirectParam` to rename the `redirect` parameter.
8
+
9
+ ## 0.12.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#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.
14
+
15
+ - [#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):
16
+
17
+ - 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.
18
+ - `tenancy.roles` maps the caller's role at every level of the chain.
19
+ - New `tenancy.family` option.
20
+ - 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.
21
+ - Console `authorize` helpers, the MCP dev tools, and the new `runWithoutRequiredTenant(fn)` pass `required: false`.
22
+ - `describeRbac` reports the `tenantChain`.
23
+
3
24
  ## 0.11.0
4
25
 
5
26
  ### Minor Changes
package/dist/console.d.ts CHANGED
@@ -53,28 +53,45 @@ export declare class AuthzConsoleGate {
53
53
  /** @internal Runs `test` for the call's user and turns the answer into a console result. */
54
54
  check(context: ExecutionContext, test: (user: User) => Promise<boolean>): Promise<ConsoleAuthorizeResult>;
55
55
  }
56
+ /** Sends a guest to the app's sign-in page instead of the console's bare 401. */
57
+ export interface ConsoleLoginOptions {
58
+ /**
59
+ * The app's sign-in path, for example `'/auth/login'`. When set, a guest (no user) gets
60
+ * `{ redirectTo: '/auth/login?redirect=%2Fdurable' }`: a console page redirects there, and
61
+ * a console API call answers 401 with that `redirectTo`, which the console follows. A
62
+ * signed-in user without access still gets 403 (redirecting would loop). Must be a
63
+ * same-origin path.
64
+ */
65
+ loginPath?: string;
66
+ /** The query parameter carrying the way back. Default `'redirect'`. */
67
+ redirectParam?: string;
68
+ }
56
69
  /**
57
70
  * Allows a console to a user holding any of `roles` (persisted or on the user object, the
58
- * same check as `@Roles()`; `superAdmin` applies). A guest is `unauthenticated`, a user
59
- * without the role `forbidden`.
71
+ * same check as `@Roles()`; `superAdmin` applies). A guest is `unauthenticated` (or sent to
72
+ * `loginPath`), a user without the role `forbidden`.
60
73
  *
61
74
  * ```ts
62
- * DurableModule.forRoot({ authorize: authorizeByRoles({ roles: ['admin'] }) })
75
+ * DurableModule.forRoot({
76
+ * authorize: authorizeByRoles({ roles: ['admin'], loginPath: '/auth/login' }),
77
+ * })
63
78
  * ```
64
79
  */
65
80
  export declare function authorizeByRoles(options: {
66
81
  roles: readonly string[];
67
- }): ConsoleAuthorizerClass;
82
+ } & ConsoleLoginOptions): ConsoleAuthorizerClass;
68
83
  /**
69
84
  * Allows a console to a user granted `permission` (persisted, through roles or directly,
70
85
  * wildcards apply; the same check as `@Permission()`; `superAdmin` applies).
71
- * A guest is `unauthenticated`, a user without it `forbidden`.
86
+ * A guest is `unauthenticated` (or sent to `loginPath`), a user without it `forbidden`.
72
87
  *
73
88
  * ```ts
74
- * TelescopeModule.forRoot({ authorize: authorizeByPermission('telescope.view') })
89
+ * TelescopeModule.forRoot({
90
+ * authorize: authorizeByPermission('telescope.view', { loginPath: '/auth/login' }),
91
+ * })
75
92
  * ```
76
93
  */
77
- export declare function authorizeByPermission(permission: string): ConsoleAuthorizerClass;
94
+ export declare function authorizeByPermission(permission: string, options?: ConsoleLoginOptions): ConsoleAuthorizerClass;
78
95
  /**
79
96
  * Allows a console to calls sending `Authorization: Bearer <token>` (compared in constant
80
97
  * time). Anything else is `unauthenticated`. Throws when `token` is empty.
@@ -1 +1 @@
1
- {"version":3,"file":"console.d.ts","sourceRoot":"","sources":["../src/console.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,0BAA0B,EAEhC,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,KAAK,gBAAgB,EAKrB,KAAK,IAAI,EACV,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,KAAK,EAAE,IAAI,EAA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AgB,EACzB,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,OAAO,CAAC,GACrC,OAAO,CAAC,sBAAsB,CAAC;CAMnC;AAED,iFAAiF;AACjF,MAAM,WAAW,mBAAmB;IAClC;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,uEAAuE;IACvE,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AA+ED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE;IAAE,KAAK,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,GAAG,mBAAmB,GAC1D,sBAAsB,CAsBxB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CACnC,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,mBAAmB,GAC5B,sBAAsB,CAqBxB;AAID;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE;IACxC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;CAC3B,GAAG,CAAC,OAAO,EAAE,gBAAgB,KAAK,sBAAsB,CAexD"}
package/dist/console.js CHANGED
@@ -18,6 +18,7 @@ import { Gate } from './gate.js';
18
18
  import { PermissionPolicy } from './policies/permission.policy.js';
19
19
  import { RolePolicy } from './policies/role.policy.js';
20
20
  import { AuthzRbac } from './rbac.js';
21
+ import { runWithoutRequiredTenant } from './tenant-override.js';
21
22
  /**
22
23
  * The token Aviary consoles resolve `authorize: '<gate name>'` through. `AuthzModule`
23
24
  * provides it globally.
@@ -76,7 +77,8 @@ let AuthzConsoleGate = class AuthzConsoleGate {
76
77
  /** @internal Runs `test` for the call's user and turns the answer into a console result. */
77
78
  async check(context, test) {
78
79
  const user = await this.userOf(context);
79
- if (await test(user))
80
+ // Console access is not a tenant-scoped read: `tenancy.required` never denies it.
81
+ if (await runWithoutRequiredTenant(() => test(user)))
80
82
  return true;
81
83
  return user === null ? unauthenticated() : false;
82
84
  }
@@ -89,13 +91,78 @@ AuthzConsoleGate = __decorate([
89
91
  AuthzRbac, Object])
90
92
  ], AuthzConsoleGate);
91
93
  export { AuthzConsoleGate };
94
+ function checkLoginPath(name, options) {
95
+ const path = options?.loginPath;
96
+ if (path === undefined)
97
+ return;
98
+ if (typeof path !== 'string' ||
99
+ !path.startsWith('/') ||
100
+ path.startsWith('//') ||
101
+ path.includes('\\') ||
102
+ path.includes('#')) {
103
+ throw new Error(`${name}: \`loginPath\` must be a same-origin path without a fragment, such as '/auth/login'.`);
104
+ }
105
+ const param = options?.redirectParam;
106
+ if (param !== undefined && (typeof param !== 'string' || param.trim() === '')) {
107
+ throw new Error(`${name}: \`redirectParam\` must be a non-empty string.`);
108
+ }
109
+ }
110
+ /** The path (with query) of a same-origin URL, or `undefined`. */
111
+ function sameOriginPath(url, host) {
112
+ if (url.startsWith('/') && !url.startsWith('//'))
113
+ return url;
114
+ try {
115
+ const parsed = new URL(url);
116
+ return host !== undefined && parsed.host === host
117
+ ? `${parsed.pathname}${parsed.search}`
118
+ : undefined;
119
+ }
120
+ catch {
121
+ return undefined;
122
+ }
123
+ }
124
+ /**
125
+ * Where a guest goes back to after signing in: the page itself on a page load, the page that
126
+ * made the call (`Referer`, same host only) on a console API call.
127
+ */
128
+ function returnPath(context) {
129
+ const request = context.switchToHttp().getRequest();
130
+ const header = (name) => {
131
+ const value = request?.headers?.[name];
132
+ return Array.isArray(value) ? value[0] : value;
133
+ };
134
+ const host = header('host');
135
+ if (header('accept')?.includes('text/html')) {
136
+ const url = request?.originalUrl ?? request?.url;
137
+ return typeof url === 'string' ? sameOriginPath(url, host) : undefined;
138
+ }
139
+ const referer = header('referer');
140
+ return referer ? sameOriginPath(referer, host) : undefined;
141
+ }
142
+ function toLogin(result, context, options) {
143
+ const loginPath = options?.loginPath;
144
+ if (loginPath === undefined ||
145
+ typeof result !== 'object' ||
146
+ !('reason' in result) ||
147
+ result.reason !== 'unauthenticated') {
148
+ return result;
149
+ }
150
+ const back = returnPath(context);
151
+ if (back === undefined)
152
+ return { redirectTo: loginPath };
153
+ const separator = loginPath.includes('?') ? '&' : '?';
154
+ const param = encodeURIComponent(options?.redirectParam ?? 'redirect');
155
+ return { redirectTo: `${loginPath}${separator}${param}=${encodeURIComponent(back)}` };
156
+ }
92
157
  /**
93
158
  * Allows a console to a user holding any of `roles` (persisted or on the user object, the
94
- * same check as `@Roles()`; `superAdmin` applies). A guest is `unauthenticated`, a user
95
- * without the role `forbidden`.
159
+ * same check as `@Roles()`; `superAdmin` applies). A guest is `unauthenticated` (or sent to
160
+ * `loginPath`), a user without the role `forbidden`.
96
161
  *
97
162
  * ```ts
98
- * DurableModule.forRoot({ authorize: authorizeByRoles({ roles: ['admin'] }) })
163
+ * DurableModule.forRoot({
164
+ * authorize: authorizeByRoles({ roles: ['admin'], loginPath: '/auth/login' }),
165
+ * })
99
166
  * ```
100
167
  */
101
168
  export function authorizeByRoles(options) {
@@ -103,6 +170,7 @@ export function authorizeByRoles(options) {
103
170
  if (roles.length === 0) {
104
171
  throw new Error('authorizeByRoles: `roles` must name at least one role.');
105
172
  }
173
+ checkLoginPath('authorizeByRoles', options);
106
174
  let AuthorizeByRoles = class AuthorizeByRoles {
107
175
  gate;
108
176
  consoleGate;
@@ -110,8 +178,9 @@ export function authorizeByRoles(options) {
110
178
  this.gate = gate;
111
179
  this.consoleGate = consoleGate;
112
180
  }
113
- authorize(context) {
114
- return this.consoleGate.check(context, (user) => this.gate.forUser(user).allows(RolePolicy, 'has', ...roles));
181
+ async authorize(context) {
182
+ const result = await this.consoleGate.check(context, (user) => this.gate.forUser(user).allows(RolePolicy, 'has', ...roles));
183
+ return toLogin(result, context, options);
115
184
  }
116
185
  };
117
186
  AuthorizeByRoles = __decorate([
@@ -126,16 +195,19 @@ export function authorizeByRoles(options) {
126
195
  /**
127
196
  * Allows a console to a user granted `permission` (persisted, through roles or directly,
128
197
  * wildcards apply; the same check as `@Permission()`; `superAdmin` applies).
129
- * A guest is `unauthenticated`, a user without it `forbidden`.
198
+ * A guest is `unauthenticated` (or sent to `loginPath`), a user without it `forbidden`.
130
199
  *
131
200
  * ```ts
132
- * TelescopeModule.forRoot({ authorize: authorizeByPermission('telescope.view') })
201
+ * TelescopeModule.forRoot({
202
+ * authorize: authorizeByPermission('telescope.view', { loginPath: '/auth/login' }),
203
+ * })
133
204
  * ```
134
205
  */
135
- export function authorizeByPermission(permission) {
206
+ export function authorizeByPermission(permission, options) {
136
207
  if (typeof permission !== 'string' || permission === '') {
137
208
  throw new Error('authorizeByPermission: `permission` must be a non-empty string.');
138
209
  }
210
+ checkLoginPath('authorizeByPermission', options);
139
211
  let AuthorizeByPermission = class AuthorizeByPermission {
140
212
  gate;
141
213
  consoleGate;
@@ -143,8 +215,9 @@ export function authorizeByPermission(permission) {
143
215
  this.gate = gate;
144
216
  this.consoleGate = consoleGate;
145
217
  }
146
- authorize(context) {
147
- return this.consoleGate.check(context, (user) => this.gate.forUser(user).allows(PermissionPolicy, 'has', permission));
218
+ async authorize(context) {
219
+ const result = await this.consoleGate.check(context, (user) => this.gate.forUser(user).allows(PermissionPolicy, 'has', permission));
220
+ return toLogin(result, context, options);
148
221
  }
149
222
  };
150
223
  AuthorizeByPermission = __decorate([
@@ -1 +1 @@
1
- {"version":3,"file":"console.js","sourceRoot":"","sources":["../src/console.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EACL,4BAA4B,EAE5B,cAAc,GACf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAEL,MAAM,EACN,UAAU,EACV,MAAM,EACN,QAAQ,GAET,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,UAAU,E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bac.js';
4
+ import type { AuthzModuleOptions } from './types.js';
5
+ /** The process-wide slot the Aviary dev MCP endpoint serves (`@dudousxd/nestjs-agent-mcp-server`). */
6
+ export declare const DEV_TOOLS_SLOT: unique symbol;
7
+ /** One property of a {@link DevToolInputSchema}. */
8
+ export interface DevToolInputProperty {
9
+ type: 'string' | 'number' | 'integer' | 'boolean' | 'array';
10
+ description?: string;
11
+ enum?: readonly string[];
12
+ items?: {
13
+ type: 'string';
14
+ };
15
+ minimum?: number;
16
+ maximum?: number;
17
+ }
18
+ /** A dev tool's input: an object of scalar / enum / array-of-string properties. */
19
+ export interface DevToolInputSchema {
20
+ type: 'object';
21
+ properties: Record<string, DevToolInputProperty>;
22
+ required?: string[];
23
+ }
24
+ /** What a tool's `run` receives besides its input. */
25
+ export interface DevToolCall {
26
+ context: unknown;
27
+ caller: {
28
+ id: string;
29
+ via: 'token' | 'session' | 'open';
30
+ };
31
+ limits: {
32
+ maxRows: number;
33
+ maxBytes: number;
34
+ };
35
+ }
36
+ /** One developer tool, as the dev-tools slot takes it. */
37
+ export interface AuthzDevTool {
38
+ name: string;
39
+ kind: 'read' | 'action';
40
+ description: string;
41
+ input: DevToolInputSchema;
42
+ destructive?: boolean;
43
+ available?(): boolean | Promise<boolean>;
44
+ run(input: Record<string, unknown>, call?: DevToolCall): Promise<unknown>;
45
+ }
46
+ /** A `{ type, id }` reference the tools take for a subject or a resource. */
47
+ export interface AuthzDevToolsRef {
48
+ type: string;
49
+ id: string;
50
+ }
51
+ /**
52
+ * The `devTools` hooks of `AuthzModule.forRoot()`: load the real models behind the refs a tool
53
+ * asks about, so policies, `superAdmin` and the decision provider see what they see in the app.
54
+ */
55
+ export interface AuthzDevToolsOptions {
56
+ /**
57
+ * Load the subject (`{ type: 'user', id: '42' }` → your `User`). Default: `resolveUser`, when
58
+ * configured. Without either, checks receive the `{ type, id }` ref itself. Return
59
+ * `undefined`/`null` when it does not exist.
60
+ */
61
+ loadSubject?: (ref: AuthzDevToolsRef) => unknown | Promise<unknown>;
62
+ /**
63
+ * Load the resource of `authz_explain_check` (`{ type: 'Post', id: '7' }` → your `Post`).
64
+ * Default: the `resourceLoaders` entry of that type. Without either, checks receive the
65
+ * `{ type, id }` ref, which no `@PolicyFor` policy is linked to.
66
+ */
67
+ loadResource?: (ref: AuthzDevToolsRef) => unknown | Promise<unknown>;
68
+ }
69
+ /** What the tools read, at call time. */
70
+ export interface AuthzDevToolsDeps {
71
+ gate: Gate;
72
+ rbac: AuthzRbac;
73
+ options: () => AuthzModuleOptions;
74
+ }
75
+ /**
76
+ * The authz developer tools (all read-only): explain a check, and a subject's effective roles
77
+ * and permissions.
78
+ */
79
+ export declare function authzDevTools(deps: AuthzDevToolsDeps): AuthzDevTool[];
80
+ /** Why {@link registerAuthzDevTools} did or did not register. */
81
+ export type DevToolsRegistration = 'registered' | 'unsupported' | 'failed';
82
+ /**
83
+ * Register the authz tools into the dev-tools slot (created when absent), without an
84
+ * `authorize`: the dev endpoint's `devTools.authorize` gates them. A hub that says it cannot gate a
85
+ * lib without a console (`supports('endpoint-authorize')` is false) is left alone. Never throws.
86
+ */
87
+ export declare function registerAuthzDevTools(deps: AuthzDevToolsDeps): {
88
+ outcome: DevToolsRegistration;
89
+ unregister?: () => void;
90
+ };
91
+ /** Registers the authz dev tools at module init and removes them at module destroy. */
92
+ export declare class AuthzDevTools implements OnModuleInit, OnModuleDestroy {
93
+ private readonly gate;
94
+ private readonly rbac;
95
+ private readonly logger;
96
+ private readonly options;
97
+ private unregister;
98
+ constructor(gate: Gate, rbac: AuthzRbac, options?: AuthzModuleOptions);
99
+ onModuleInit(): void;
100
+ onModuleDestroy(): void;
101
+ }
102
+ //# sourceMappingURL=dev-tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dev-tools.d.ts","sourceRoot":"","sources":["../src/dev-tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,eAAe,EACpB,KAAK,YAAY,EAElB,MAAM,gBAAgB,CAAC;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