Available on non-WebAssembly only.
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. - Tamper evidence (18.33.0): each line appended to the file carries
prev(the SHA-256 of the line before it) andhash(of itself), soverify_chain—GET /admin/api/v1/audit/verify,rws ctl audit --verify [FILE]— finds an edited, removed or inserted entry.
Structs§
- Audit
Entry - One audited change.
- Chain
Report - What
verify_chainfound. - 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.
- CHAIN_
START - The
prevof a chain’s first line.
Functions§
- chain_
line json(anAuditEntry::to_jsonobject) as a chained file line after a line whoseline_hashisprev.- line_
hash - The SHA-256 of a whole line (without its newline), as the next line’s
prev. - 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). The hash chain continues from the file’s last line. - verify_
audit_ file verify_chainon the configured[admin] audit_logfile;Errwhen none is configured or it can’t be read.- verify_
chain - Check an audit log’s hash chain; stops at the first broken line.