The Big Picture

RoleAdmin access
adminEverything, always. Not part of the matrix, so nobody can be locked out.
managerWhat Admin > Users > Roles & Permissions grants.
editorWhat the matrix grants.
userNone: the public site and their profile (/users/profile) only.

A permission is <area>.<action>, for example pages.publish. The actions are:

  • view: open the area's admin pages and lists
  • create: add new records (a new page, product, widget, collection item or user; upload media; add a theme)
  • edit: change existing records (create does not include it: a role with create but not edit cannot change what it added)
  • delete: remove
  • publish: publish / unpublish (or show / hide), where the area has it

Every module with admin pages or admin APIs is an area automatically. The one extra area is dashboard. Changes in the matrix apply immediately, also to people who are signed in.

1. The Default Matrix

Applied once, on the first start (afterwards only the matrix screen changes it; Reset to defaults ticks it again):

AreaManagerEditor
Dashboardview-
Pages, Productsview, create, edit, delete, publishview, create, edit, publish
Widgetsview, create, edit, delete, publish-
Themes (add, duplicate = create; new version, name, status = edit; download = view)view, create, edit, delete- (can be granted)
Collections (items)view, create, edit, delete, publishview, create, edit, publish
Media (upload = create)view, create, edit, deleteview, create, edit
Usersview, create, edit, delete-
Statsview-

Administrators only (cannot be granted): Settings, Modules, Sites, Email, Cache, Application Logs, Audit Log, Server Status, maintenance mode, widget types (they contain HTML/JS), editing a theme's files and previewing a theme (Admin > Themes), designing collections (creating them, changing their fields, deleting them) and the matrix itself.

The matrix lists every admin menu area, in sidebar order (System entries last). Those that cannot be granted (Sites, Modules, Settings, Cache, Application Logs, Audit Log, Server Status) carry an ADMIN ONLY badge and show the manager and editor boxes disabled. The rows come from the sidebar (matrixRows() in permissions.ts), so a new menu entry appears in its place by itself; the disabled boxes are never saved.

Themes: a theme's JavaScript runs on the public site, also while an administrator is signed in and browsing it. Whoever may add or replace themes can therefore act with an administrator's rights; tick it for editors only when you trust them that far. For the same reason, editing a theme's files in the admin is for administrators only, whatever the matrix says.

Every staff member (administrators, managers, editors): the Documentation. A route opts in with permission: 'staff'.

Areas added after the first start (e.g. Collections on an existing install) start unticked: grant them in the matrix.

2. How a Request Is Checked

The admin gate (src/core/permissions.ts) runs on every /admin/* page and every /api/v1/<module>/admin/* endpoint and works out the permission the request needs:

RequestNeeds
Admin page of a module (admin.views)<module>.view
Admin API GET / HEAD<module>.view
Admin API DELETE<module>.delete
Admin API, any other method<module>.edit
Anything of an admin-only module, unknown admin pagesan administrator

Visitors and users are sent to the admin sign-in page (/admin/login: email and password, staff accounts only; Forgot password? emails staff a link to /admin/reset-password); every staff role may open My Profile (/admin/profile); staff without the permission get "Access denied" (APIs answer 403). During maintenance, staff (administrators, managers, editors) still see the public site. The sidebar, header and dashboard show only what the role may use, and each role lands on its first allowed page after signing in.

3. A Module Takes Part

Nothing is required: a new module appears in the matrix with view, create, edit, delete, all unchecked, so it stays administrator-only until boxes are ticked. Declare permissions to change that:

export const blogModule: AppModule = {
  id: 'blog',
  // ...
  permissions: {
    actions: ['view', 'create', 'edit', 'delete', 'publish'],   // default: view, create, edit, delete
    routes: {                                          // admin API routes that are not the method default
      'POST /save': 'save',                            // new and existing posts: create OR edit (see below)
      'POST /upload': 'create',
      'POST /delete': 'delete',
      'POST /publish': 'publish',
      'POST /import': 'admin',                         // administrators only
    },
    // adminOnly: true,   // the whole module is for administrators (its menu entry shows in the matrix, not grantable)
    // label: 'Blog posts', // row label in the matrix
  },
  admin: {
    views: [
      { path: '/blog', template: '...' },                           // needs blog.view
      { path: '/blog/settings', template: '...', permission: 'admin' }, // administrators only
    ],
  },
};

Routes are keyed by 'METHOD /path' below /api/v1/<id>/admin (:params allowed). A write the module does not offer (for example edit on a view-only area) stays administrator-only.

One save route for new and existing records (no id = new, as in Pages, Products, Widgets, Users and collection items): map it to 'save'. The gate then lets in anyone with create or edit, and the handler checks the right one once it knows the id:

import { canSave, saveDenied } from '../../src/core/permissions.js';

api.post('/save', async (c) => {
  const body = await c.req.json();
  const id = String(body.id || '');
  if (!(await canSave(c, 'blog', !id))) return saveDenied(c, 'posts', !id); // 403: may not create / may not edit
  // ...
});

Hide "New" buttons with {{#if can.blog.create}}; in a pop-up used for both, show Save for item ? may.edit : may.create.

Upgrading from before create (2026-10-16): once, at startup, every role that could edit an area also gets create there, so nobody loses the right to add records. Afterwards the two boxes are independent.

4. Finer Checks in Handlers

Some rules depend on the data, such as publishing on save. Check them with can():

import { can } from '../../src/core/permissions.js';

api.post('/save', async (c) => {
  // the gate already required blog.edit
  if (body.status === 'published' && !(await can(c, 'blog.publish'))) {
    return c.json({ error: 'Your role may not publish posts' }, 403);
  }
  // ...
});

The built-in rule for publishing (pages, products, widget visibility): without publish, new items are saved unpublished, existing items keep their status, and changing it is refused. For a route outside the admin prefix use requirePermission('blog.publish') as route middleware.

5. Templates and Admin Scripts

  • Templates: {{#if can.blog.delete}}...{{/if}}, isAdmin, isStaff (admin, manager or editor).
  • Admin scripts: window.__CAN__.blog.delete (set by the admin layout).

Hiding a button is for convenience only; the gate and the handlers enforce every rule on the server.

6. Users and Roles

  • Administrators create and manage every account and give any role.
  • Managers (with users.edit / users.delete) create, edit, (de)activate and delete editors and users only. They see administrators and managers read-only and cannot change their own role.
  • Nobody deletes or deactivates their own account, and the last active administrator stays an active administrator.
  • Self-registration uses the "Default Role for New Users" setting (keep it on User).

7. Audit Log

Admin > Audit Log (administrators only) lists who did what: the action, the record (type, id, name), details, IP and path, with filters and a per-record history. Record your own actions with:

import { audit } from '../../src/core/audit.js';

await audit(c, 'blog.publish', { type: 'post', id, label: title }, { previous: 'draft' });

8. Test It

import { buildApp, createRoleUser } from '../helpers/app.js';

const app = await buildApp();
const editor = await createRoleUser('editor');   // { id, email, cookie }
const res = await app.request('/api/v1/blog/admin/list', { headers: { cookie: editor.cookie } });
expect(res.status).toBe(403);                     // not granted yet

Change grants in a test with setRolePermissions('editor', [...]) and restore them afterwards.