@dudousxd/nestjs-authz-mikro-orm 0.7.1 → 1.0.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 +23 -0
- package/README.md +20 -6
- package/package.json +10 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# @dudousxd/nestjs-authz-mikro-orm
|
|
2
2
|
|
|
3
|
+
## 1.0.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`750a6b3`](https://github.com/DavideCarvalho/nestjs-authz/commit/750a6b3f80deea3803dec8df5f9f8cf67a046ac1)]:
|
|
8
|
+
- @dudousxd/nestjs-authz@0.10.0
|
|
9
|
+
|
|
10
|
+
## 0.8.0
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- [#67](https://github.com/DavideCarvalho/nestjs-authz/pull/67) [`32e967f`](https://github.com/DavideCarvalho/nestjs-authz/commit/32e967ffbcd68a97e8effc77af9c16bbbafdc918) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Run on `@dudousxd/nestjs-authz` 0.9 and `@nestjs/authorization`: persisted roles and
|
|
15
|
+
permissions now guard routes through the official guard as the core's `RolePolicy` /
|
|
16
|
+
`PermissionPolicy` (`@Roles('editor')`, `@Permission('posts.publish')`), and the guard and the
|
|
17
|
+
handler's `Gate` calls share one permission and role fetch per request. The store API
|
|
18
|
+
(role sources, admin management, tenant-scoped roles where supported) and `AuthzRbacModule`
|
|
19
|
+
are unchanged. A persisted permission named like a policy ability no longer bypasses that
|
|
20
|
+
policy (see the core changeset). Requires NestJS 12, `@nestjs/authorization` ^0.1.3 and Node 22+.
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- [#67](https://github.com/DavideCarvalho/nestjs-authz/pull/67) [`32e967f`](https://github.com/DavideCarvalho/nestjs-authz/commit/32e967ffbcd68a97e8effc77af9c16bbbafdc918) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Fix packages that could be published without files their `exports` point to. `tsc` builds no longer use a `.tsbuildinfo` that can outlive `dist/` and skip emitting files. A new `check:exports` step (also `prepack`) fails the release if any `exports`/`main`/`types` path is missing.
|
|
25
|
+
|
|
3
26
|
## 0.7.1
|
|
4
27
|
|
|
5
28
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# @dudousxd/nestjs-authz-mikro-orm
|
|
2
2
|
|
|
3
3
|
MikroORM RBAC persistence for [`@dudousxd/nestjs-authz`](https://github.com/DavideCarvalho/nestjs-authz) —
|
|
4
|
-
roles
|
|
4
|
+
roles and permissions for the official `@nestjs/authorization` policies, with **zero connection ownership** (your app owns the
|
|
5
5
|
`EntityManager`; this package never opens a connection).
|
|
6
6
|
|
|
7
7
|
This is the MikroORM sibling of `@dudousxd/nestjs-authz-typeorm`: identical store surface
|
|
@@ -15,7 +15,7 @@ separate `@mikro-orm/decorators` package), so no extra peer is required.
|
|
|
15
15
|
## Install
|
|
16
16
|
|
|
17
17
|
```bash
|
|
18
|
-
pnpm add @dudousxd/nestjs-authz-mikro-orm @dudousxd/nestjs-authz @mikro-orm/core @mikro-orm/nestjs
|
|
18
|
+
pnpm add @dudousxd/nestjs-authz-mikro-orm @dudousxd/nestjs-authz @nestjs/authorization @mikro-orm/core @mikro-orm/nestjs
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
## Entities
|
|
@@ -110,16 +110,30 @@ import { EntityManager } from '@mikro-orm/core';
|
|
|
110
110
|
export class AppModule {}
|
|
111
111
|
```
|
|
112
112
|
|
|
113
|
-
Once wired,
|
|
113
|
+
Once wired, persisted roles and permissions guard routes through the official
|
|
114
|
+
`@nestjs/authorization` guard, as the core's `RolePolicy` / `PermissionPolicy`:
|
|
114
115
|
|
|
115
116
|
```ts
|
|
116
|
-
await store.givePermissionToRole('editor', 'posts
|
|
117
|
+
await store.givePermissionToRole('editor', 'posts.*');
|
|
117
118
|
await store.assignRole({ type: 'user', id: 7 }, 'editor');
|
|
118
119
|
|
|
119
|
-
|
|
120
|
-
|
|
120
|
+
@Permission('posts.publish') // posts.* grants it
|
|
121
|
+
@Can(PermissionPolicy, 'has', permission('posts.publish')) // the same, spelled out
|
|
122
|
+
@Roles('editor') // @Can(RolePolicy, 'has', roles('editor'))
|
|
121
123
|
```
|
|
122
124
|
|
|
125
|
+
and in services, through the `Gate`:
|
|
126
|
+
|
|
127
|
+
```ts
|
|
128
|
+
gate.forUser(user).allows('posts.publish'); // true (PERMISSION_PROVIDER seam)
|
|
129
|
+
gate.forUser(user).allows(PermissionPolicy, 'has', 'posts.publish');
|
|
130
|
+
gate.forUser(user).hasRole('editor'); // true (ROLE_PROVIDER seam)
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
The user is the one the official guard reads (`AuthorizationModule.forRoot({ getUser })`,
|
|
134
|
+
default `request.user`), mapped to a store ref with `userRefFrom` (default `{ type, id }` or
|
|
135
|
+
`{ id }`).
|
|
136
|
+
|
|
123
137
|
## Schema
|
|
124
138
|
|
|
125
139
|
`autoCreateSchema` (default `true`) runs `ensureAuthzSchema` on `onModuleInit` via MikroORM's
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dudousxd/nestjs-authz-mikro-orm",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "MikroORM RBAC persistence for @dudousxd/nestjs-authz — roles, permissions, and a Gate seam (zero connection ownership).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -38,11 +38,12 @@
|
|
|
38
38
|
"CHANGELOG.md"
|
|
39
39
|
],
|
|
40
40
|
"peerDependencies": {
|
|
41
|
-
"@dudousxd/nestjs-authz": ">=0.
|
|
41
|
+
"@dudousxd/nestjs-authz": ">=0.10.0",
|
|
42
42
|
"@mikro-orm/core": "^6.0.0 || ^7.0.0",
|
|
43
43
|
"@mikro-orm/nestjs": "^5.0.0 || ^6.0.0 || ^7.0.0",
|
|
44
|
-
"@nestjs/
|
|
45
|
-
"@nestjs/
|
|
44
|
+
"@nestjs/authorization": "^0.1.3",
|
|
45
|
+
"@nestjs/common": "^12.0.0",
|
|
46
|
+
"@nestjs/core": "^12.0.0",
|
|
46
47
|
"reflect-metadata": ">=0.1.13"
|
|
47
48
|
},
|
|
48
49
|
"peerDependenciesMeta": {
|
|
@@ -54,21 +55,22 @@
|
|
|
54
55
|
"@mikro-orm/better-sqlite": "6.6.16",
|
|
55
56
|
"@mikro-orm/core": "6.6.16",
|
|
56
57
|
"@mikro-orm/nestjs": "6.1.2",
|
|
58
|
+
"@nestjs/authorization": "0.1.3",
|
|
57
59
|
"@nestjs/common": "12.0.1",
|
|
58
60
|
"@nestjs/core": "12.0.1",
|
|
59
61
|
"@nestjs/testing": "12.0.1",
|
|
60
|
-
"@types/node": "20.
|
|
62
|
+
"@types/node": "22.20.5",
|
|
61
63
|
"reflect-metadata": "0.2.2",
|
|
62
64
|
"rxjs": "7.8.2",
|
|
63
65
|
"typescript": "5.9.3",
|
|
64
66
|
"vitest": "3.2.7",
|
|
65
|
-
"@dudousxd/nestjs-authz": "^0.
|
|
67
|
+
"@dudousxd/nestjs-authz": "^0.10.0"
|
|
66
68
|
},
|
|
67
69
|
"engines": {
|
|
68
|
-
"node": ">=
|
|
70
|
+
"node": ">=22"
|
|
69
71
|
},
|
|
70
72
|
"scripts": {
|
|
71
|
-
"build": "tsc -p tsconfig.json",
|
|
73
|
+
"build": "tsc -p tsconfig.json --incremental false",
|
|
72
74
|
"test": "vitest run --passWithNoTests",
|
|
73
75
|
"test:watch": "vitest",
|
|
74
76
|
"typecheck": "tsc -p tsconfig.json --noEmit"
|