Expand description
Who may do what on the admin API (18.22.0, #75): users, roles and the audit log.
- Users: the
[admin] token_envtoken is useradminwith roleadmin;[admin] users = ["deploy-bot:RWS_ADMIN_DEPLOY:operator"]adds named tokens (name:ENV_VAR:role), and OIDC sign-in maps groups to roles. - Roles:
viewerreads everything (everyGET);operatoralso reloads, drains, switches maintenance, blocks IPs, flips flags, purges caches and renews certificates;adminalso changes authorization tuples.required_roleis the one table. - Audit log: every change (and every refused attempt) as a JSON line
— time, user, role, how they signed in, source address, method, path,
the body with secrets redacted, the status — kept in memory (the last
AUDIT_CAPACITY) and appended to[admin] audit_logwhen set. MCP tools that change the server record here too.
Structs§
- Audit
Entry - One audited change.
- McpAudit
Layer - Audits
tools/callrequests for the named MCP tools (the ones that change the server) as usermcp, with the arguments redacted like an admin request body. Wrap the MCP server with it. - Principal
- Who made a request.
- Token
User - A user with a bearer token.
Enums§
- Role
- What a user may do; ordered (
Viewer < Operator < Admin).
Constants§
- AUDIT_
CAPACITY - Entries kept in memory.
Functions§
- node_
name - This replica’s name in audit entries and cluster heartbeats.
- parse_
role_ map group=roleentries (comma-separated): a group (or an email address, or*for anyone signed in) → role. First match in order wins.- parse_
users name:ENV_VAR:roleentries (comma-separated) → users whose token is inENV_VAR.Errnames the first bad entry or unset variable.- recent_
json - The
nnewest entries, newest first, as a JSON array. - record
- Record a change.
- record_
change - Record a change made by
principalfromaddress. - redact
- A request body for the log: a JSON object’s secret-looking values
replaced by
"(redacted)", anything longer than 2 KB cut. - required_
role - The role a request needs: reads are
viewer, authorization tuplesadmin, any other changeoperator. - role_
for - The role
mapgives a user withemailandgroups: the highest of the entries that match;Nonewhen none does. - set_
audit_ file - Append audit entries to
pathtoo (empty: memory only).