A permission is a named capability, such as message.post or room.create. A role is a named set of decisions about permissions. Each decision allows or denies one permission in one scope.
For each action, Chatto finds the explicit decisions that apply to the user and combines them with a small set of rules. If no decision applies, the server denies the action. A role name or a role rank gives no authority. The only exception is the owner.
Roles carry decisions, not rank
Each role, also admin, gives only its explicit decisions (ADR-040). A role has a position, but the position controls only the display order.
The system roles are owner, admin, moderator, and everyone (FDR-001). Each authenticated human user belongs to everyone automatically, and can have more roles. A decision can also apply to one user directly.
A bot is different. It does not inherit everyone or a named role. It has only the permissions that someone allows to it directly, and never more than its human owner has (FDR-001).
An action on another user needs a concrete permission, not a higher rank. For example, role.assign controls role assignment. A user can assign a role only if they have each permission that the role allows.
Scopes, and how one check resolves
A decision is set at one of these scopes: Server, Room group, or Room. A room group is a set of channel rooms that share permissions. Each channel room belongs to exactly one group (ADR-031).
For each role, Chatto uses the nearest decision: Room first, then Room group, then Server. A room decision replaces the group and server decisions of the same role for that room. It does not change the decisions of a different role.
A new server gives the usual member permissions to everyone at server scope, so ordinary rooms work immediately (ADR-040). Decisions for a group or a room are local exceptions.
The server resolves each permission in this order (ADR-052):
- An owner whose override is active is allowed.
- The user and each assigned role give their nearest decision. If one of them denies, the result is a denial.
- The nearest decision of
everyoneis the baseline. An allow from step 2 overrides a denial ofeveryoneonly at the same scope or a nearer scope. - If nothing decides, the server denies the action.
The announcements room of a new server shows the rule. The room denies message.post to everyone and allows it to admin, both at room scope (ADR-031). Ana has the admin role, so she can post. Ben has only everyone, so he cannot. A server-wide allow from a different role does not help Ben, because the room denial is nearer.
A permission can include another permission. The permission catalog states each inclusion explicitly. For example, message.read includes message.read-interactions.
Owners and privileged mode
An owner is a user with the owner role. Owners are entitled to all permissions, and no stored decision can change that (ADR-040). Thus an owner cannot lock themselves out with an unusual configuration.
The entitlement is not always in effect. The owner override applies only while the session of the owner has privileged mode active with the owner role selected (ADR-105). The app calls this Shield Mode. Without it, an owner resolves through the rules above like each other user.
Privileged mode belongs to one session and has a fixed 15-minute deadline (ADR-096). Use of a permission does not extend the deadline. Activation gives no new permission: it only makes the grants of the selected protected roles usable. Direct user grants and grants from unprotected roles apply without it. A bot cannot activate privileged mode.
Direct messages and the permission to read
A direct message (DM) is a room without a room group. Membership is the privacy boundary: only a participant can find or use a DM. An owner does not bypass this rule.
For permissions, all DMs share one scope named Direct messages. A DM check uses Direct messages first, then Server. All message.* permissions apply there, and no room.* permission does (ADR-095).
To read messages, membership is necessary but not sufficient. The user also needs message.read (ADR-080). This permission gates timelines, search, attachments, message notifications, typing indicators, and live delivery of message events. A new server gives it to everyone at server scope.
Reading and writing stay separate. message.read does not permit a user to post, and message.post does not permit a user to read.
A check that a concurrent change cannot corrupt
The API handler only identifies the caller. The core service of the domain owns the authorization, the validation, and the write (ADR-115). Thus each transport gets the same decision.
A permission decision reads data from more than one place: roles, room groups, and user accounts. One of them can change while the server decides. Chatto solves this without a lock (ADR-087). The command:
- records the last log position of each authorization input:
evt.rbac.>,evt.group.>, andevt.user.>; - waits until the projections have applied those positions;
- makes the complete decision;
- reads the positions again;
- does steps 1 to 4 again if a position changed.
Then the command appends its fact with optimistic concurrency control. The append succeeds only if no other fact changed the target, for example the room, after the command read it. If the append fails, the command does its domain checks and its authorization again.
A change that arrives after step 4 is concurrent with the command and does not cancel it. A change that arrives during the decision always causes a new decision. The rule uses no lock in one process, so it also holds with more than one server process.
Read the code
- cli/internal/core/permission_resolver.go: the resolution order for one user and one permission.
- cli/internal/core/permissions.go: the permission definitions.
- cli/internal/core/authorization_consistency.go: the stable read of the authorization inputs.
- cli/internal/core/privileged_mode.go: privileged mode for a session.
- cli/internal/core/rbac_seed.go: the roles and decisions of a new server.