nocobase-app-plugin-authz-restriction-rules
What it does
This skill adds restriction rules that narrow which records an action can reach in a NocoBase 3 app. It is for administrators who must keep certain records out of reach for some users.
When to use it
- ✓When some teams must never see certain records, such as confidential projects.
- ✓When a limit should apply across every path to a collection.
- ✓When you need to check or manage existing restriction rules in production.
Skill link
https://github.com/nocobase/nocobase/blob/v3-develop/packages/plugins/app-plugin-authz-restriction-rules/skills/nocobase-app-plugin-authz-restriction-rules/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agent’s skills folder.
Example of what to ask your AI
“Can you make sure the engineering team can never see confidential projects in my NocoBase app?”
5 new skills a week. 1 minute to read.
How it works
The AI creates a rule that intersects the records an action reaches with the allowed selection, for the listed subjects. Restriction rules only narrow access and never grant it.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
Develop restriction rules
A restriction rule intersects the records an action reaches with the rule's selection, for the subjects it lists. The selection describes the records still allowed, not the records to hide. Several matching restrictions all apply; none can grant an action or widen a range.
Read the installed nocobase-app-plugin-authorization Skill first for composite resources, data scopes, fields, server policy enforcement and inherited subjects. The package README at node_modules/@nocobase/app-plugin-authz-restriction-rules/README.md is the complete reference for the service, the HTTP routes and the exports; this Skill covers how to use them.
For a restriction assigned to a department, or to the root department for the whole company, read the application development Skill's references/organization/permission-design.md first. Its core works with permission sets alone and says how to keep excluded records out without this plugin; its optional restriction section covers this one.
Development workflow
- State the invariant positively, for example "this team may access only non-confidential projects". Define who it applies to and whether it covers one operation or every path to a collection.
- Use a rule on a composite, with
scopeKey, for an operation-specific limit. For a limit across every business branch, create a rule on thedatabase.collectionwith its CRUD actions; declared business data scopes and collection-wide invariants are both provisioned through the HTTP routes or the service. - Register a suitable record access and save the complete rule. Apply the restriction directly to a user as well when it must remain after that person's team membership is removed.
- Bind policies on all protected reads and writes. For relation targets, declare relation record access explicitly; a standalone collection restriction is not inherited by nested relation writes.
- Verify the excluded row stays inaccessible after adding broad sharing and another permission set, across each protected operation, and that unrelated actors keep their intended access.
For example, a confidentiality restriction assigned directly to each account holds whichever permission set grants the action. Test with ordinary users: unrestricted identities skip every rule.
Install
Register the default export of @nocobase/app-plugin-authz-restriction-rules/client in client/plugins.ts and of @nocobase/app-plugin-authz-restriction-rules/server in server/plugins.ts, beside the main authorization plugin, and run the application's migrations. Add the factory to the plugins of server/config/authorization.ts, merged with the application's other rule factories:
import { restrictionRules } from '@nocobase/app-plugin-authz-restriction-rules/server';
import {
defineAppConfig,
type AppConfigFactory,
} from '@nocobase/app-server/config';
import type { AuthorizationConfig } from '@nocobase/app-plugin-authorization/server';
const authorization: AppConfigFactory<AuthorizationConfig> = defineAppConfig(
() => ({ plugins: [restrictionRules()] }),
);
export default authorization;
During setup the factory registers the settings item authorization.restriction-rules (group authorization, actions read, create, update, delete) and its routes under /api/authorization/restrictionRules, which the running application documents at /api/swagger/docs under the Authorization tag. Without the factory in the configuration the plugin adds no API and no route.
Service API
Resolve authorizationToken from @nocobase/app-plugin-authorization/server in the owning provider or route factory. The rule API exists only when the factory is configured, so narrow the service before using it. quotes is the application's own composite, sales.public its own record access and org.team its own subject type, all defined as the main Skill describes.
import { selection } from '@nocobase/authorization/core';
import {
defineRestrictionRule,
type RestrictionRulesAuthorizationApi,
} from '@nocobase/authorization/restriction-rules';
import type { DatabaseConnection } from '@nocobase/db';
if (!('restrictionRules' in authz))
throw new Error('Restriction rules is not configured');
const rules = (
authz as typeof authz & RestrictionRulesAuthorizationApi<DatabaseConnection>
).restrictionRules;
await rules.create(
defineRestrictionRule('public-proposals', quotes.reference())
.title('Exclude confidential
FAQ
Can a restriction give access?
No. It only narrows what is already allowed.
Do several rules combine?
Yes. All matching restrictions apply at the same time.
How is it different from default access?
Default access sets a shared baseline, while restriction rules narrow what people can reach.
Details
Original description by the author
Design, implement and verify restriction rules for NocoBase 3 business operations, including named data scopes and production administration.
repo: nocobase/nocobase
Popularity
- GitHub stars
- 25k
- Ranking position
- #10092
- License
- —
- Updated
- 11/2/2026
Comments
- …
More skills from this repository
nocobase-app-development
25kHelps your agent build pages, routes, data, permissions, and tests for a complete NocoBase 3 business application.
shadcn
25kHelps your agent find, add, fix, and style shadcn/ui components in a web project, using their official docs and registries.
nocobase-app-plugin-development
25kHelps your agent create and maintain NocoBase 3 plugins inside an existing app, including server, client, database, and registration parts.
nocobase-app-upgrade
25kHelps your agent upgrade a NocoBase app to a newer template release, bringing in template changes while keeping your own work.
Similar skills
reverse-engineer-anything
422kHelps your agent look inside shipped apps and packages to explain features, compare versions, or guide a rebuild, using the REA tool.
1password
394kHelps your agent set up the 1Password CLI, sign in, and read or inject secrets without printing their values into chat.
healthcheck
394kHelps your agent audit the computer or server that runs OpenClaw for security risks, such as SSH, firewall, updates, and backups, then suggest safe fixes.