@dudousxd/nestjs-authz 0.9.0 → 0.9.2

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,17 @@
1
1
  # @dudousxd/nestjs-authz
2
2
 
3
+ ## 0.9.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#70](https://github.com/DavideCarvalho/nestjs-authz/pull/70) [`416f0bd`](https://github.com/DavideCarvalho/nestjs-authz/commit/416f0bd7d9340f6f3314017d4925cb89834c4342) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - README fixes: the codegen README no longer describes the removed `PostPolicy` → `Post` name guess and lists `@PolicyFor` among the names that must not be aliased; the core README covers the dropped `DecisionProvider` deny message and the expected boot error under `unannotated: 'allow'`.
8
+
9
+ ## 0.9.1
10
+
11
+ ### Patch Changes
12
+
13
+ - [#68](https://github.com/DavideCarvalho/nestjs-authz/pull/68) [`febcbc8`](https://github.com/DavideCarvalho/nestjs-authz/commit/febcbc8d2ac290d0f155ea505d2668ef28a4ce17) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Depend on `@dudousxd/nestjs-diagnostics` `>=0.7.0 <1.0.0` instead of the exact `0.7.1`, so an app on diagnostics 0.8.0 shares one copy (and one channel and capability registry) instead of installing a second one.
14
+
3
15
  ## 0.9.0
4
16
 
5
17
  ### Minor Changes
package/README.md CHANGED
@@ -189,6 +189,7 @@ decorators are gone: move each one to its official form.
189
189
  | `gate.allows()` user from nestjs-context | `AuthenticationContext.user` inside its scope (`null` there is a guest), nestjs-context outside it |
190
190
  | a persisted permission named like a policy ability grants it | the policy decides (only `superAdmin` bypasses it), in checks and in `scope()` |
191
191
  | `DecisionProvider` / `superAdmin` see a guest as `undefined` | `null` |
192
+ | a `DecisionProvider` deny `message` (`{ allowed: false, message }`) is the 403's message | dropped: the 403 is the official `{ statusCode: 403, message: 'Forbidden' }`. `@nestjs/authorization` has no deny-with-reason (a policy returns `true` or denies; an exception it throws counts as a failure, not a denial). To show a reason, throw your own `ForbiddenException(reason)` from the ability. A route then gets your body, but no `denied` event is emitted and `AuthorizationService.can()` throws instead of returning `false`. |
192
193
  | `DecisionProvider` asked by the Gate on every check | asked by `AuthzPolicy.before()` on routes, and by `Gate` string abilities |
193
194
  | `import … from '@dudousxd/nestjs-authz-inertia/client'` | `import … from '@dudousxd/nestjs-authz-client'` (the subpath is removed) |
194
195
 
@@ -223,6 +224,18 @@ has no such option):
223
224
  and 403 for a user, same `denied` event. A route with no requirement is let through. The app
224
225
  fails to start if the official global guard is still on, because it would keep denying them.
225
226
 
227
+ **The boot log has one expected ERROR in this mode.** `@nestjs/authorization` checks at
228
+ startup that a guard enforces each `@Can()`, and it recognizes only its own
229
+ `AuthorizationGuard`. It does not see `AuthzGuard`, so it logs:
230
+
231
+ ```text
232
+ ERROR [Authorization] @Can() is not enforced on PostController.update, … : AuthorizationModule has
233
+ globalGuard: false, and these handlers have no @UseGuards(AuthorizationGuard).
234
+ ```
235
+
236
+ That is safe: `AuthzGuard` enforces those handlers, and `AuthzModule` logs a line right after
237
+ it naming them. The error goes away at step 4.
238
+
226
239
  2. **Drop the 0.8 guard and move the old decorators.** Remove `RolesGuard` / `CanGuard` from
227
240
  `APP_GUARD` and `@UseGuards()`, and rewrite each string `@Can` / `@Policy(Post)` with the table
228
241
  above (`@Can('page.documents')` → `@Can(GatePolicy, 'allows', ability('page.documents'))`).
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare const VERSION = "0.9.0";
1
+ export declare const VERSION = "0.9.2";
2
2
  export { AuthzModule } from './module.js';
3
3
  export { AuthzGuard } from './authz.guard.js';
4
4
  export { Gate, BoundGate } from './gate.js';
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // Rewritten from this package's package.json by `scripts/sync-version.mjs`, which the root
2
2
  // `version-packages` script runs right after `changeset version`. The build is plain `tsc`
3
3
  // and injects nothing, so the literal below is what ships in dist.
4
- export const VERSION = '0.9.0';
4
+ export const VERSION = '0.9.2';
5
5
  // Extras on top of @nestjs/authorization. Its own API (@Policy, @Can, Can.Anyone,
6
6
  // AuthorizationModule, AuthorizationService, AuthorizationGuard) is imported from there.
7
7
  export { AuthzModule } from './module.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dudousxd/nestjs-authz",
3
- "version": "0.9.0",
3
+ "version": "0.9.2",
4
4
  "description": "Extras on top of @nestjs/authorization: persisted RBAC policies, @Can helpers (byId, roles, permission), a Gate with batch checks and ad-hoc gates, super-admin, query scoping.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -52,7 +52,7 @@
52
52
  "skills"
53
53
  ],
54
54
  "dependencies": {
55
- "@dudousxd/nestjs-diagnostics": "0.7.1"
55
+ "@dudousxd/nestjs-diagnostics": ">=0.7.0 <1.0.0"
56
56
  },
57
57
  "peerDependencies": {
58
58
  "@dudousxd/nestjs-context": ">=0.1.0",