Canonical role names app:role with application-scope confinement
Status
Section titled “Status”Accepted.
Approx. 2026-10-15 (role/name.go added that day, following the bug-fix series recorded in platform-bug-fixes.md).
Context
Section titled “Context”Roles bundle permissions and are assigned to principals by name. Two things made names unreliable.
First, nothing validated them. A role assignment stored whatever string the writer sent; the SDK sync lower-cased it, the admin create did not. An assignment naming a role that did not exist resolved to no permissions at token-mint time, silently: the principal simply had less access than intended, with nothing logged.
Second, applications sync their own roles and principals. Without a rule tying a role to its application, one application could grant another application’s roles.
Names can also be abused cosmetically. A name with whitespace, zero-width characters or look-alike characters can render as a real role.
Decision
Section titled “Decision”- A role name is canonical
{applicationCode}:{roleName}: two or more colon-separated, non-empty segments. Multi-colon names such asportal:dashboard:userare tolerated so stored definitions stay valid. - Each segment uses ASCII letters, digits,
_,.and-. No whitespace of any kind, no control or zero-width characters. - A malformed name is rejected with
400 INVALID_ROLE_NAME, never trimmed or repaired, so the audit trail holds exactly what the caller sent. Permissions have their own shape check (INVALID_PERMISSION, which also allows the*wildcard). - Case is not constrained by the shape rule, because stored data already contains both.
- The SDK sync is confined to the application. Role names in a principal sync are matched lower-cased and as given (the platform adds no prefix). A name that is not a role is skipped and reported in
skippedRoleswhile the rest applies. A role belonging to another application refuses the whole sync with403 ROLE_APP_FORBIDDEN. - Role sync cannot grant above the caller: a platform permission a synced role gains or loses must be one the caller holds, else
403 PERMISSION_ABOVE_CALLER, all-or-nothing. - In tokens, the
applicationsclaim carriesid:codepairs or*, and roles are filtered to the client’s applications when a client is application-scoped.
Consequences
Section titled “Consequences”Good:
- Role names are unambiguous and safe to render, log and compare.
- One application cannot escalate by naming another’s roles.
- Typos surface at write time as a 400 instead of as missing access at sign-in.
Bad:
- Existing data with non-canonical names was tolerated, not migrated, so some stored names are still odd.
- There is no database foreign key from assignments to roles (see no foreign keys), so the guarantee rests on the write paths.
- The case rule is loose: two names differing only in case are distinct strings.
Alternatives considered
Section titled “Alternatives considered”| Alternative | Why not |
|---|---|
| Trim and normalise silently | Hides caller bugs and changes what the audit trail records. |
| A foreign key from assignments to roles | Ruled out by the no-foreign-keys decision; also roles are synced in batches. |
| Role ids instead of names in sync payloads | Ids differ per environment, which defeats code-first sync. |