@rhino-dev/rhino-nestjs 4.7.2 → 4.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/README.md +2 -2
- package/dist/interfaces/rhino-config.interface.d.ts +17 -0
- package/dist/policies/resource-policy.d.ts +9 -0
- package/dist/policies/resource-policy.js +12 -0
- package/dist/policies/resource-policy.js.map +1 -1
- package/dist/services/query-builder.service.d.ts +62 -2
- package/dist/services/query-builder.service.js +192 -19
- package/dist/services/query-builder.service.js.map +1 -1
- package/dist/services/resource.service.js +19 -10
- package/dist/services/resource.service.js.map +1 -1
- package/dist/services/scope.service.d.ts +19 -1
- package/dist/services/scope.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/stubs/skills/rhino-policy.md +3 -1
package/package.json
CHANGED
|
@@ -12,6 +12,7 @@ Rhino policies check `{slug}.{action}` permissions. The base `ResourcePolicy` cl
|
|
|
12
12
|
1. Restrict which fields users can **write** (`permittedAttributesForCreate` / `permittedAttributesForUpdate`)
|
|
13
13
|
2. Restrict which fields users can **read** (`permittedAttributesForShow` / `hiddenAttributesForShow`)
|
|
14
14
|
3. Add custom authorization logic beyond permission checks (e.g., "only the author can edit")
|
|
15
|
+
4. Restrict which named scopes a user may select with `?scope=` (`permittedScopes`)
|
|
15
16
|
|
|
16
17
|
Read the following before writing any code:
|
|
17
18
|
- `src/policies/resource-policy.ts` — the base class
|
|
@@ -166,7 +167,8 @@ npm test -- --testPathPattern=post.policy
|
|
|
166
167
|
|
|
167
168
|
- Do not forget to call `super.update(...)` etc. in overridden action methods — skipping it bypasses the permission check entirely.
|
|
168
169
|
- `hasRole(user, 'admin')` checks the role in the current organization context stored on the user object. If organization context is not set, it returns false.
|
|
169
|
-
- Return `['*']` (not `[]`) from `permittedAttributesForShow` when all fields should be visible — `[]` means nothing is visible.
|
|
170
|
+
- Return `['*']` (not `[]`) from `permittedAttributesForShow` when all fields should be visible — `[]` means nothing is visible. The same goes for `permittedScopes`.
|
|
171
|
+
- A field hidden by `hiddenAttributesForShow` is also refused as a `?filter[]` or `?sort` and skipped by `?search=`, so hiding a column no longer leaves it usable as a query predicate.
|
|
170
172
|
- The `resourceSlug` on the policy must match the key in `RhinoModule.forRoot({ models: { [slug]: ... } })`.
|
|
171
173
|
|
|
172
174
|
## Permission Reference
|