Ace commands
Manage roles and permissions from the command line.
configure registers the commands barrel. All commands boot the app and use the
configured store.
authz:make-role
node ace authz:make-role editorCreate a role (idempotent).
authz:make-permission
node ace authz:make-permission posts.editCreate a permission. Names may be dotted/wildcard (e.g. posts.*).
authz:grant
node ace authz:grant editor posts.editGrant a permission to a role (creating either by name as needed).
authz:assign
node ace authz:assign editor 42
node ace authz:assign editor 42 --type=admin --tenant=acmeAssign a role to a user. --type sets the polymorphic user type (default
user); --tenant scopes the assignment (omit for the global scope).
authz:list
node ace authz:listList every role (with its permissions) and every permission.
authz:sync
node ace authz:syncSeed roles and permissions from the catalog declared in config/authz.ts.
Idempotent — only missing rows are created/attached.
defineConfig({
catalog: {
permissions: ['system.manage'],
roles: {
editor: ['posts.*'],
viewer: ['posts.view'],
},
},
})Roles relation
authzRolesRelation() — the Lucid manyToMany options that join your user model to the authz roles through the authz_user_role pivot, so a listing preloads roles instead of asking once per user.
Testing
Use the memory store and the shared store contract suite to test authorization deterministically.