Roles and permissions
Set who can read or write each resource; Charter enforces it on every request.
A role is a free-form string on a user (for example user, editor or admin). There is no separate roles table. Import creates a role name the first time a permission row mentions it. You may assign roles with charter users update --role, and list them with charter roles ls.
Conventional names in the examples are public (unauthenticated), user (any signed-in caller) and admin, plus custom names such as agent or editor. They are conventions only, not hard-coded defaults.
To see the model in one place, here is a create permission that injects author_id from the caller, and an update permission that limits edits to the author's own rows:
[[permissions]]
resourceName = "posts"
role = "user"
action = "create"
fields = ["title", "body", "author_id"]
checks = [{ field = "author_id", operator = "eq", claim = "id" }]
[[permissions]]
resourceName = "posts"
role = "user"
action = "update"
fields = ["title", "body"]
filters = [{ field = "author_id", operator = "eq", claim = "id" }]
Operator versus role admin#
Calling a role admin is not enough for operator routes. /registry/* and HTTP /mcp (Admin MCP) require an operator account (admin_since set). Grant that with charter admin grant. Role admin still participates in /v1 permission matching like any other role. Resource MCP at /v1/mcp uses a normal API principal, not the operator gate.
Three layers#
Each permission is one (resource, role, action) row in [[permissions]] (or via the CLI / registry). Actions are create, read, update and delete. Config import also accepts import for CSV import grants; the HTTP registry and MCP permission tools only use the four CRUD actions.
| Layer | When it applies | What it does |
|---|---|---|
fields |
create, read, update (empty list is fine for delete) | Which attributes the role may see or write |
filters |
read, update, delete | Row-level WHERE clauses |
checks |
create, update | Values Charter injects or enforces on write |
The same permission rows gate REST /v1, Admin MCP record reads (as CHARTER_MCP_ROLE), Resource MCP record tools (as the caller's user role), and ?include= sideloads.
Filters#
Enforced operators: eq, neq, gt, gte, lt, lte, in, nin, is_null, is_not_null. Anything else fails closed.
Each constraint names a field and an operator, plus either a literal value or a claim.
Checks#
The only enforced check operator is eq. On create or update, a check with claim or value makes that field optional in the client body and overwrites whatever the client sent.
Claims#
The only claim Charter resolves today is id (the caller's user UUID). Unknown claims, including email or dotted paths such as metadata.org_id, fail closed.
Warning
MCP tool calls carry no per-user identity. Filters or checks that use claim = "id" match nothing over Admin MCP. See MCP.
Authenticating requests#
On the free binary, Charter is one instance: users live in metadata_users with no organization container. The Pro binary can add organizations, invitations, and organization-scoped OpenID Connect (OIDC) single sign-on (SSO). See Organizations. Permission claims on /v1 still resolve only id (the caller's user UUID).
Pass a credential on every /v1 call:
curl http://127.0.0.1:3000/v1/posts \
-H "Authorization: Bearer crt_…"
Supported credentials:
- Opaque API keys prefixed
crt_…(mint withcharter api-keys create, or the/api/auth/api-keyendpoints) - Short-lived PASETO access tokens from sign-in, refresh or
POST /api/auth/exchange - Session cookie
charter_auth_session_tokenfor browser flows
Email and password sign-up and sign-in live under /api/auth/.... Optional Google and GitHub OAuth turn on when AUTH_GOOGLE_* or AUTH_GITHUB_* are set. See Environment variables.
Service accounts (no password) are created with charter service-account.