Access and roles
Give each person a role. Editors write, writers send their work for review, and viewers read. For Studio and Agency plans.
On Studio and Agency plans, each person who signs in has a role. A role decides what they can change, and the server checks it on every request. The admin also hides or disables what a role cannot do, so nobody is offered a button that will be refused.
| Role | What it may do |
|---|---|
admin |
Everything: settings, the agent’s instructions, the license key, proposals and every entry. |
editor |
Writes entries directly, applies and rejects proposals, adds and deletes images. |
writer |
Reads. Saving, creating and deleting send a proposal for review instead. Adds images and asks the agent. |
viewer |
Reads entries, images, proposals and settings. Changes nothing. |
Each role holds everything the one below it does, and more. On Solo everyone is an admin, whatever is set up here; Settings shows the roles with a note saying which plans add them.
Telling prime who is asking
auth can return an identity instead of true. prime then gives that person a role.
import { defineConfig } from "@getprimecms/core";
import { basicAuth, fromHeader } from "@getprimecms/server";
export default defineConfig({
// A few people with passwords, each with a role:
auth: basicAuth({
users: [
{ username: "ada", password: process.env.ADA_PASSWORD!, role: "editor", email: "ada@example.com" },
{ username: "wren", password: process.env.WREN_PASSWORD!, role: "writer" },
],
}),
// Or read who your proxy says it is, such as Cloudflare Access:
// auth: fromHeader({ email: "cf-access-authenticated-user-email" }),
access: {
users: { "ada@example.com": "editor", "wren@example.com": "writer" },
collections: { writer: ["posts"] },
},
});
A person’s role is the first of these that applies:
- A
rolein the identityauthreturns. - Their email in
access.users. access.defaultRole. Left out, it isvieweronce you list users, so someone nobody mentioned can only read, andadminotherwise, so a site that has not set up roles behaves as it always did.
Your own auth function can return { id, email, name, role } as well. fromHeader trusts the headers it reads, so use it only when your proxy removes them from outside requests and nothing reaches the site except through it. Security explains how to check that on Cloudflare.
Writers send their work for review
A writer’s save does not change the file. It becomes a proposal in the same Reviews queue as the agent’s, with the writer named as the author, and an editor or admin applies or rejects it.
- It is checked the way a direct save is: against the version the writer opened, and against your fields. If someone changed the entry in the meantime, the writer is told to reload and submit again.
- Saving again replaces that writer’s own pending proposal for the entry, so five saves leave one proposal, not five. Another writer’s proposal is never touched.
- A save that changes nothing makes no proposal.
- A new entry or a deletion is a proposal too. Renaming an entry needs an editor.
- When the agent proposes something for a person, the proposal says who asked.
Limiting a role to some collections
access.collections limits a role to the collections you list. The others are hidden from that person, refused on every request, and left out of proposals and of where an image is used. Admins are never limited.
The agent reads the whole site, so a person limited to some collections cannot use it.
What it does not do
Roles apply to a whole collection, not to single fields or entries. prime records who proposed what, and git records who changed files, but there is no separate audit log. The Settings page shows people without access what is configured, read-only, but only admins see who has which role.