perfgate-auth
Authentication and authorization types for the perfgate baseline service.
Part of the perfgate workspace.
Problem
The baseline service controls who can read, write, promote, and delete baselines -- scoped to projects and optionally to benchmarks. This crate defines the shared type vocabulary used by server, client, and CLI.
Key Types
| Type | Purpose |
|---|---|
ApiKey |
Authenticated key with project scope, role, and optional benchmark regex |
Role |
Viewer, Contributor, Promoter, Admin -- cumulative scopes |
Scope |
Granular permission: Read, Write, Promote, Delete, Admin |
JwtClaims |
JWT payload accepted by the server (subject, project, scopes, expiry) |
API Key Format
pg_live_<32+ alphanumeric>-- production keyspg_test_<32+ alphanumeric>-- test/sandbox keys
validate_key_format() enforces prefix and length; generate_api_key(test) mints new keys.
Roles and Scopes
Viewer -> [Read]
Contributor -> [Read, Write]
Promoter -> [Read, Write, Promote]
Admin -> [Read, Write, Promote, Delete, Admin]
Role::from_scopes() infers the closest built-in role from an arbitrary scope
set, useful when mapping JWT claims to role-based checks.
Example
use ;
let key = new;
assert!;
assert!;
assert!;
License
Licensed under either Apache-2.0 or MIT.