Members, roles and data scopes
Membership controls project access, role permissions control operations, and data scopes control the records those operations can access. Run the examples from the entry repository, substituting your project code for order-center.
./kaiwu whoami
./kaiwu access permissions order-center
./kaiwu access roles order-center
./kaiwu access members order-centerGrant a read-only role
In Project Management, open the project’s permission center, create a role, grant its menu permissions and assign it to an existing user. This example assumes alice exists and manifest sync has registered order:order:list.
./kaiwu access role-create order-center auditor --name "Auditor"
./kaiwu access role-grant order-center auditor --permissions order:order:list
./kaiwu access member-set order-center alice --roles auditorrole-grant replaces the role’s permission set. member-set replaces the member’s roles and enables the membership by default. Read current assignments before modifying an existing object. Read them back, sign in as the member, and verify both UI hiding (via useCan / <Can> from @/kaiwu) and backend enforcement.
In product-led projects, demo personas (mock-support/personas.ts) map to roles defined in frontend kaiwu/roles.yml. The first ./kaiwu project adopt <frontend-dir> --apply imports those initial roles automatically; subsequent runs and regular project sync preserve manual platform edits unless --with-access is explicitly passed.

Filter order rows
When coding agents generate CRUD endpoints, the most common security gap is checking menu permissions while forgetting row-level isolation. Kaiwu enforces row scopes across Gateway and Starter without adding runtime callbacks:
- Five fixed scope types with role union: Supports
ALL,DEPT_AND_CHILD,DEPT,SELF, andCUSTOM_DEPT(with optional child departments). Multiple roles resolve to their union, and unconfigured roles default toSELF. - Zero-callback signed propagation: System resolves the scope snapshot and Gateway embeds the
dsclaim into the 60s signed Context. Business services never call back to System on normal requests. - Table-level SQL enforcement & build gates: Add
com.kaiwuzaidao:kaiwu-data-scope:0.2.0todomain, register its interceptor before pagination, and declare protected tables (or explicitexemptreasons) inkaiwu/data-scopes.ymlunderMETA-INF/kaiwu/. Indexedowner_user_idandowner_dept_idcolumns are auto-filled on insert; ownership transfers useDataScopes.reassign, background jobs use auditedDataScopes.unrestricted("reason", ...), andDataScopeConventionTestchecks ownership fields and indexes, rejects references to protected tables inJdbcTemplatesource, and warns about potentially undeclared list, page, or export endpoints.
Sync the resources, configure per-role scopes in the permission center, and verify two owners across list results, paginated totals, and out-of-scope updates. Integration code · Platform scope rules