Skip to content

7e. Who can do what: the four roles (0.32.0)

Until 0.32.0 every account on a host could do everything every other account could do. Roles fix that. There are four, they are ordered, and each one includes everything below it:

Role What it adds
viewer Reads. Deployments, runtime, logs and log streams, source, readiness, jobs, specs, routing, custom routes, registries, host variables (never a secret’s value), notifiers and their deliveries, the control stack, the swarm, node stats, terminal-session history, and the list of accounts
developer Stacks. Submit and delete deployments, up / down / verify / sleep / wake, start / stop / restart a container, cancel a job, mint a share link, open a container shell, write and delete named specs, create, assign and delete custom routes
maintainer The host’s configuration. Host variables and secrets, private-registry logins, Traefik dynamic files, notifiers (create, edit, test, redeliver), the swarm join token, and reading the SSO configuration
admin People. Create, delete and re-role accounts, set someone else’s password, write the SSO configuration, and apply a sealed config. Also the pressure and prune settings

Two things sit outside that ladder:

  • root — whoever holds PSTACK_TOKEN. Not a role, not an account, and above all four. It is also the only principal that may GET/POST /api/config, the plaintext export of every credential on the host (7d); an admin session is 403 there, deliberately.
  • A share link is not a weak role. It reaches exactly the views it was minted with, on exactly its own deployment, GET only (share links). Roles changed nothing about it.

The table below is the whole of it. Anything not listed — a route that does not exist, a method a route does not answer — is root’s alone: the gate is default-deny, so a new route is closed to every account until someone puts it in the table.

Route Least role
GET /api/health none — it is how init waits for the container
GET /api/auth/grafana/verify · /start none — verify decides by its own cookie; viewers get 403
GET /api/auth/me · POST /api/auth/logout any account
GET/POST /api/tokens · DELETE /api/tokens/:id any account (they are already scoped to the caller)
PUT /api/users/:id/password for yourself any account
every GET in the viewer row above, including GET /api/users viewer
PUT/DELETE /api/deployments/:id developer
POST /api/deployments/:id/{up,down,verify,sleep,wake} developer
POST /api/deployments/:id/cancel — stop the running and queued jobs for a stack developer
POST /api/deployments/:id/containers/:name/{start,stop,restart} developer
POST /api/deployments/:id/share · POST /api/jobs/:id/cancel developer
WS /api/deployments/:id/terminal developer
PUT/DELETE /api/specs/:name developer
POST /api/custom-routes · DELETE /api/custom-routes/:name · PUT/DELETE /api/custom-routes/:name/assignment developer
PUT/DELETE /api/host-vars/:name · /api/registries/:host · /api/routing/:file maintainer
POST/PATCH/DELETE /api/notifiers… (incl. /test, /redeliver) maintainer
GET /api/swarm/join maintainer
GET /api/control/runtime · POST /api/control/restart maintainer
GET/PUT /api/domains maintainer
GET /api/tls · POST /api/tls/redeploy maintainer
PUT/DELETE /api/tls/wildcard admin
GET/PUT /api/logging maintainer
PUT /api/logging/storage admin
GET /api/forward maintainer
PUT/DELETE /api/forward — it decides where every deploy runs admin
GET /api/scaler · GET /api/scaler/presets · GET /api/scaler/presets/:name maintainer
PUT /api/scaler · PUT/DELETE /api/scaler/presets/:name — they decide what machines this host pays for, and a preset is code admin
GET /api/sso/config maintainer
GET /api/settings viewer
PUT /api/settings/max_jobs maintainer
PUT /api/settings/default_role admin
PUT /api/settings/{pressure_disk_pct,pressure_mem_pct,pressure_cpu_load,pressure_sleep_idle_min,image_prune_after_h} admin
POST /api/users · PATCH/DELETE /api/users/:id admin
PUT /api/users/:id/password for anybody else admin
PUT/DELETE /api/sso/config · /api/sso/config/:key admin
POST /api/config/sealed admin
GET/POST /api/config root token only
GET /api/scaler/config · POST /api/scaler/report — the scaler’s own; config carries the cloud credentials root token only

Four of those rows are decisions rather than deductions, and each looks wrong until you hold it next to the thing beside it:

  • The container shell is a developer’s, not an admin’s. A developer can already up an arbitrary compose file on this host — including a service that mounts the Docker socket — so refusing them a shell would be theatre while the larger door stands open. If that bothers you, the door to close first is up.
  • GET /api/swarm/join dropped from admin to maintainer. It is a host-configuration read and it belongs with the others. It is still a real credential — the token joins a machine to your cluster — so it stops at maintainer and goes no lower.
  • Writing the SSO configuration is admin, though every other host-configuration write is maintainer. A provider’s defaultRole mints accounts at whatever role it names, so a maintainer who could point this host at an identity provider they control would be able to sign in through it as an admin. That is a promotion path, and promotion paths live with people. Reading the configuration stays maintainer — it returns a mask, never the client secret.
  • The runtime settings split by KEY, not by route. max_jobs is operational and sits with host configuration at maintainer; default_role decides what every account created without an explicit role can reach, which is user management by another name, so it sits with the promotion paths at admin. The five pressure keys are admin too: 0 turns a guard off for every node. Reading any of them is a viewer’s — the page that shows the cap is the page everybody sees, and each row carries the role it takes to change it.

A refusal says which role was wanted and which one you hold, because an operator staring at a bare forbidden cannot tell a wrong role from a wrong URL:

Terminal window
$ curl -s -X PUT https://api.preview.example.com/api/host-vars/DSN \
-H "cookie: $SESSION" -d '{"value":"…","secret":true}'
{
"error": "this route requires the maintainer role or higher — you are a developer"
}

A role is set when the account is created and changed with PATCH. Both are admin’s (or root’s):

Terminal window
$ curl -s -X POST https://api.preview.example.com/api/users \
-H "authorization: Bearer $PSTACK_TOKEN" \
-d '{"username":"dana","password":"…","email":"dana@example.com","role":"developer"}'
{ "user": { "id": 7, "username": "dana", "role": "developer", … } }
$ curl -s -X PATCH https://api.preview.example.com/api/users/7 \
-H "authorization: Bearer $PSTACK_TOKEN" -d '{"role":"maintainer"}'
{ "updated": 7, "role": "maintainer" }
  • A personal access token inherits its owner’s role and can never exceed it. The CI job holding one is that person, with that person’s permissions — so a viewer’s token cannot deploy.
  • A promotion or demotion takes effect on that account’s next request. Sessions and tokens are deliberately not revoked: every request reads the role fresh, and logging somebody out is a worse signal, not a stronger one.
  • The last admin cannot be deleted or demoted — not by another admin, and not by the root token either. PSTACK_TOKEN may live only in a CI secret store or have been rotated away from every human on the team, and a host with zero admin accounts cannot create one through the API; the repair is a hand-edited database over SSH. Promote a replacement first: cannot demote the last admin — promote another account first.

Upgrading a host that already has accounts

Section titled “Upgrading a host that already has accounts”

Nothing breaks and nobody is locked out. The role column has carried a default of admin since it was added, so every account that exists on your host today is already an admin and keeps doing exactly what it did before. There is no migration to run and no window in which somebody cannot log in. Roles only start to matter for the accounts you create after the upgrade — and for the ones you deliberately demote.

Demote deliberately, on your own schedule. PATCH /api/users/:id one at a time, leaving at least one admin behind.

⚠️ Breaking: POST /api/users no longer creates an admin.

It takes an optional role, and an absent role now means the least privilege, where it used to silently mean the most. A script or a provisioning step that relied on the old behaviour has to say "role": "admin" and mean it.

Since 0.33.0 an absent role means the host’s default_role setting — viewer until an admin sets it, and never admin by omission (Runtime settings). So it can be raised, but only on purpose, and only by somebody who could already create the account.

The same route is now admin-only. Previously it was reachable by any authenticated principal and always created an admin, which meant any account on the host could mint itself a second, fully privileged one. That was the hole this release closes.

An unknown role is a 400 naming the four, rather than a stored value that quietly reaches nothing.

This is coarse, role-based access control: four fixed tiers, one ordered comparison, one table. It is deliberately the smallest thing that removes “every account can do everything”, and it buys you the ordinary team shape — a contractor who can look, a developer who can deploy, an operator who holds the host’s secrets.

It is not a policy engine and not multi-tenancy. There is no “developer, but only on pr-*”, no “maintainer of these three registries”, no per-deployment ownership. Those are attribute-based questions, and answering them properly means a real isolation boundary underneath — separate VMs or namespaces, a credential boundary, a per-tenant Docker — not more rows in this table. ABAC is the direction this would grow in if it grows; adding attributes to these four tiers without the boundary underneath would buy the appearance of isolation and none of it. Until then: one host, one trust level per tier, and a developer who can up an arbitrary compose file is trusted with the host.