Skip to main content

Module rbac

Module rbac 

Source
Available on crate feature serve only.
Expand description

Role-based access control for the faucet serve control plane (#205).

The default single---auth-token mode is one implicit admin principal. A --auth-config <file> promotes serve to a multi-principal deployment: a list of { name, token, role } principals, each token mapped to a Role that grants a fixed set of Permissions. Every /v1 route declares the permission it needs (required_permission); the auth middleware (serve::auth::require_auth) resolves the bearer token to an AuthContext and denies (403) any request whose role lacks the permission.

Tokens are compared in constant time (via serve::auth::constant_time_eq) and never appear in {:?} output — PrincipalSpec’s Debug masks them, and the server registers every token with the redaction writer at startup.

Structs§

AuthContext
The resolved identity for one request, carried in the request extensions for handlers (and the audit writer) to read. Holds no token.
PrincipalSpec
One principal entry in an --auth-config file: a human-readable name, its bearer token, and the role it is granted.
RbacConfig
A validated RBAC configuration: a non-empty set of principals with unique names and unique, non-empty tokens.

Enums§

Permission
A discrete capability a route requires. Roles grant a fixed set of these.
Role
A named role. Roles are a fixed, built-in ladder — vieweroperatoradmin — chosen so the common cases (read-only dashboard user, run operator, full admin) need no custom permission wiring.

Functions§

audit_action
A short, stable audit action label for a (method, matched-route) pair.
required_permission
The permission a (method, matched-route-template) pair requires. None means the route has no specific mapping and is therefore admin-only (fail closed for any route added without an explicit entry here).