canopy-security API Reference
Overview
Cross-link: canopy-security Data Model (#419)
Central audit and security service. Subscribes to ALL events via RabbitMQ wildcard (#) routing key, persists them with SHA-256 hash chain integrity, runs background breach detection, and provides APIs for audit review and compliance reporting.
- Base URL
-
container port 8012 (host:
CANOPY_PORT_CANOPY_SECURITY_8012in.ports.env); every route below is mounted under/v1, behind the identity receiver, except canopy-identity’s own routes (below):GET /identity/jwks,POST /identity/token,POST /identity/revoke,POST /identity/device_authorization,POST /identity/device_verification, the security-administration routes under/identity/admin/andGET /.well-known/oauth-authorization-server/identity - Authentication
-
Bearer token on the
/v1routes: a canopy-identity token for this receiver (itsaudisurn:canopy:service:canopy-security), authenticated by the service’s identity receiver (ADR-049 Amendment 14), which reads the keys in process from the JWKS memo below rather than over HTTP (main.rs): no bearer is 401token_missing, a token it refuses 401token_rejected, anX-Canopy-Actorheader 400actor_header_retired, and no trustworthy key set in time 503keys_unavailable. - Access
-
canopy-caps, canopy-eligibility, canopy-medicaid, canopy-portal, canopy-snap, canopy-tanf, canopy-web and canopy-wic hold a system edge to canopy-security; canopy-web and canopy-cli carry workers' delegations. The house admission is
SERVICE_OR_ADMIN(system;admin), widened on the audit reads to canopy-web’s and canopy-cli’s readers; the archive run, the export and admin replay are user-only, and the audit ingest, the signing-key registry and the worker observation system-only (the ingest also admits the portal’sportal:audit:write). A refusal is 403 with itsReceiverDenialcode (ADR-049 Amendment 14); each route’s constant is in the authorization inventory. - Swagger UI
-
/swagger-uion the same host port - Database
-
canopy_security
Admission specifics
Legend: system is any system caller but the portal; portal (scope) the portal’s system token holding that scope; a role or bar alone, a user’s delegation through any client holding one of its roles; … via canopy-web, canopy-cli, a delegation only through those clients. Worker reader is WORKER_READER_ROLES, audit reader AUDIT_READER_ROLES (admin, studio_admin or auditor; both in crates/canopy-auth/src/roles.rs).
-
GET /v1/security/events: a user who holds no audit-reader role must name onehousehold_id, else 403 with no code (require_case_scope,api/events.rs; ADR-049 Amendment 15). -
POST /v1/security/audit/ingest: the portal’sapplicant.session.mintedevent must carry anX-Canopy-Applicantclaim binding itsresource_id(require_owned_application: 403ownership_claim_missingorownership_mismatch); the check is inert for other callers. The row’ssource_serviceisprincipal.client()(#2649). -
POST /v1/security/signing-keys: the system caller’s client id must sign for the program (signing_authz::allowed_signing_programs: canopy-snap, canopy-tanf, canopy-medicaid formedicaidandchip, canopy-caps, canopy-wic), else 403 with no code. -
GET /v1/security/chain/verify-jobs/{id}: a system caller sees only the jobs its client id requested (another’s is 404); anadminsees every job. -
Attribution,
{subject}being the user’s canopy subject (principal.attribution_sub()): a chain verify job’srequested_byis the system caller’s client id, elseadmin:{subject}; an archive run’srequested_byisadmin:{subject}; the export’saudit.export.requestedevent records{subject}asactor.
Audit Events
GET /v1/security/events
List audit events with filtering and pagination.
- Access
-
system;
admin; worker reader via canopy-web, canopy-cli (delegated::SECURITY_GET_SECURITY_EVENTS); a user without an audit-reader role must name ahousehold_id(Admission specifics)
Query parameters:
| Parameter | Type | Description |
|---|---|---|
|
integer |
Page size (default: 50) |
|
integer |
Offset for pagination |
|
string |
Filter by originating service (e.g., |
|
string |
Filter by event type (e.g., |
|
string |
Filter by action |
|
uuid |
Filter audit events to a single household. Required by the worker portal Audit section, backed by the |
|
string[] (repeated) |
Program-scope visibility filter (#1519, ADR-044). Repeated |
Response (200): Array of AuditEvent objects. For a row that arrived as an event envelope, the user_id / user_role pair is the actor the intake derived (#1008): when the event named a typed Actor, user_id is the human’s OIDC subject or the service’s principal and user_role is human or service; otherwise user_role is whatever the payload or fact author_type carried, minus those two reserved values. A row from POST /v1/security/audit/ingest stores the caller’s user_id / user_role as sent, except that a reserved human / service role is dropped. The derivation is on canopy-security Data Model (Actor derivation).
audit_events table only — rows older than the operator-set archive
age threshold have moved to audit_events_archive and do not appear here.
History contracts ride the by-id lookup (archive ∪ live), the FOIA export union
(GET /v1/export/audit-events), the fact-history endpoint, and the keyset
GET /v1/security/archive list.
GET /v1/security/events/{id}
Get a single audit event by ID. Reads archive ∪ live (#1208): the live PK probe first, else the archive twin — an archived row keeps resolving.
- Access
-
system;
admin; audit reader via canopy-web, canopy-cli (delegated::SECURITY_GET_SECURITY_EVENTS_ID)
Response (200): AuditEvent object.
Response (404): Event not found.
GET /v1/security/persons/{person_id}/fact-history/{resource}
The scoped, transaction-time change-history of one person’s eligibility
facts (#674, ADR-027 §4). Projects the append-only audit_events
ledger to the attributed *.claimed / income.closed events canopy-persons
emits (#673), filtered to one person and one resource kind, ordered by the
hash-chain insert time (created_at, strictly increasing) — oldest first. One
resource returns a fact type’s full history (claims, corrections, and the
close); the entry action distinguishes them.
Path parameters:
| Parameter | Type | Description |
|---|---|---|
|
uuid |
The person whose fact history is queried (matched against the |
|
enum |
One of |
Response (200): Array of FactChangeEntry objects, each carrying
person_id, fact_id, version_id (claim only), action (claim / close),
actor_sub / actor_role (the authoring worker/applicant; on a close, the closing
worker the persons primitive’s author_sub named — #874; actor_sub is null for an
applicant author, which has no sub; both are null only on a pre-#874 close row),
claim_source, claim_status, the
opaque per-kind before (superseded windows) and after (new value; null for a
close), recorded_at (the audit row’s transaction-time), and the opaque
event_hash. Since #687 (ADR-036) the PII money leaves inside
before/after are sealed (a SealedValue envelope — canopy-security never
holds the DEK), so this endpoint surfaces ciphertext for them and the worker UI
renders a (sealed) marker; the structural discriminators (*_type, frequency)
stay plaintext. The actual figure is read from the system-of-record (canopy-persons)
— see #920.
Response (400): Unknown resource. 403: the admission’s refusal.
- Access
-
system;
admin; worker reader via canopy-web, canopy-cli (delegated::SECURITY_GET_SECURITY_PERSONS_PERSON_ID_FACT_HISTORY_RESOURCE). The admission is by role alone: canopy-web applies the worker’s program-scope view gate (#632) before it resolves the household’s members and fans out here per member to compose the household view (services/canopy-web/src/api/fact_history.rs). canopy-security stays a self-contained leaf (ADR-001): it calls no other service.
audit_events hash is SHA-256 over the
RFC 8785 (JCS) bytes of the AuditChainInputs struct
(services/canopy-security/src/store/mod.rs), whose fields include the actor
(user_id/user_role; metadata.author rides inside metadata), action,
resource, source_service, household_id, and metadata itself (the
before/after, hashed as stored). Verification is
server-side (verify_chain recomputes each row with the single chain formula;
#687 dropped the legacy v1 formula + the per-row hash_version); the
event_hash returned here stays an opaque integrity token — it is not
independently recomputable from this DTO (FactChangeEntry omits the hashed
previous_hash/event_id/timestamp fields of that struct), so a client treats
it as a correlation handle, not a recompute input.
POST /v1/security/audit/ingest
HTTP audit ingress for broker-less services (ADR-026). canopy-security normally ingests audit events via the RabbitMQ wildcard subscriber, but the applicant portal (canopy-portal) is Postgres- and RabbitMQ-free, so its session security events (mint / revoke / kill-switch) post here instead. The server mints the event_id and chains the row through the same chain append the subscriber uses (store::append_audit_events, ADR-014), in a transaction of its own: the 202 is sent only after that commit, one request at a time (the subscriber’s batching, below, does not apply here). An HTTP-ingested event is indistinguishable from a broker-ingested one in the chain.
- Access
-
system; portal (
portal:audit:write) (inlineAdmission::system().and_portal("portal:audit:write"), #1441): a user is 403system_caller_required, the portal without the scopeportal_scope_missing; the portal’sapplicant.session.mintedevent also needs its ownership claim (Admission specifics).
The row’s source_service is the authenticated client’s id (principal.client(); the portal’s events stamp canopy-portal), on both arms (#2649). The request carries no such field, and a body that still names one has it ignored.
Callers post this best-effort / fire-and-forget — a canopy-security outage must never break the applicant flow, so the portal logs and drops failures rather than retrying them into the request path.
Request: AuditEventIngestRequest
{
"event_type": "applicant.session.minted",
"action": "created",
"resource_type": "applicant_session",
"resource_id": null,
"user_id": null,
"user_role": null,
"ip_address": null,
"household_id": null,
"metadata": { "flow_kind": "resume" },
"event_timestamp": null,
"programs": []
}
event_timestamp defaults to the ingest time and metadata to {} when omitted. A user_role of human or service is dropped (the row stores no role): those values are reserved for an event that names a typed Actor (#1008). household_id is parsed to a UUID for the typed audit_events.household_id column; a non-UUID drops to NULL before the hash is computed — insert_audit_event parses it, normalized_metadata_and_hash hashes the parsed value (NULL as JSON null) as the AuditChainInputs.household_id field, and verify_chain recomputes over the stored column (services/canopy-security/src/store/mod.rs) — so the drop never breaks the chain.
programs (#1519) is the publisher’s program-scope assertion for the row’s audit_events.programs column: [] = asserted program-neutral (visible to every scoped worker view), ["snap", …] = the named storage slugs, omitted/null = no assertion — the store then derives from the event-type routing key or the curated neutral families, else stores NULL (invisible to scoped worker views; see the worker-portal audit model in authorization-inventory.adoc). An assertion containing an unknown slug is rejected as a whole — the row stores NULL, with no fall-through to derivation (a malformed assertion must not be partially honored or silently re-derived). Unlike household_id, the column is OUTSIDE the AuditChainInputs hash: household_id is a hashed field of that frozen struct, while programs is an INSERT bind the hash never sees (the dedup_key precedent) (services/canopy-security/src/store/mod.rs — the AuditChainInputs struct, normalized_metadata_and_hash on the insert path, verify_chain's recomputation, and the insert_audit_event binds; the 20261128000000 migration header records the programs tamper-evidence posture). The inside/outside field list has one owner — the Chain input paragraph under "Core tables" in canopy-security Data Model (#2137). The "frozen v1" wording in that header and in event_parsing.rs names the pre-chain-v2 audit_events chain (the live one, as against the dormant chain-v2 substrate), not the legacy hash_version = 1 formula — ADR-014 Amendment 3 (#687) removed that formula and its per-row selector, leaving the single AuditChainInputs formula.
The endpoint is mode-split (#1207, ADR-014 Amendment 7). Because chain-v2 is withdrawn (ADR-041; ADR-014 Amendment 12), along with the #1279 cutover that would have turned CANOPY_SECURITY__CHAIN_V2_APPEND_ENABLED on, the flag stays off and v1 is the live mode until #1304 retires the v2 arm:
-
v1 (flag off, today’s production): Response (202): accepted and synchronously chained (no body). 403: the admission’s refusal, or the session event’s ownership claim missing or mismatched.
-
chain-v2 (flag on):
202is REDEFINED as accepted + durably staged — the row is idempotently staged (chain_append_staging) and the per-shard drainer chains it asynchronously. The body carries the server-minted receipt{"event_id": "<uuid>"}— the event’s permanent replay identity. A client retry WITHOUT its own idempotency key mints a NEW event (intentional: replay identity belongs to the server-minted envelope id, not the request body). 422:metadatacarries an integer outside the RFC 8785-safe range (±(2^53 − 1)), or — since #1205 — the raw body fails the JSON number fence (#1285: a number token whose decimal value differs from its f64 round-trip, the collision class hash recomputation cannot see) — the client-traceable I-JSON classes; any other build failure is a redacted 500. 503 (fixed detailaudit staging at capacity): the staging admission cap is reached — retry later.
Breach Alerts
GET /v1/security/alerts
List breach detection alerts.
- Access
-
system;
admin; audit reader via canopy-cli (delegated::SECURITY_GET_SECURITY_ALERTS)
Query parameters: limit, offset, status
Response (200): Array of BreachAlert objects.
GET /v1/security/alerts/{id}
Get a single alert.
- Access
-
system;
admin(SERVICE_OR_ADMIN,api/mod.rs)
Response (200): BreachAlert object.
Response (404): Alert not found.
PATCH /v1/security/alerts/{id}
Update alert status (acknowledge, investigate, resolve).
- Access
-
system;
admin(SERVICE_OR_ADMIN)
Request: UpdateAlertStatus
{
"status": "in_progress",
"resolved_by": "auditor@example.gov"
}
status is one of open, in_progress, resolved, false_positive (the breach_alerts_status_check CHECK); any other value is 422 check_violation (the shared database mapping).
status is required; resolved_by is optional.
Response (200): updated BreachAlert object.
Response (404): Alert not found.
NIST Controls
GET /v1/security/nist-controls
List all NIST SP 800-53 control mappings tracked by the system.
- Access
-
system;
admin; audit reader via canopy-cli (delegated::SECURITY_GET_SECURITY_NIST_CONTROLS)
Response (200): Array of NistControlMapping objects with control ID, description, and implementation status.
Integrity and Summary
GET /v1/security/summary
Get aggregate audit statistics (per-service action counts) over a trailing time window.
- Access
-
system;
admin; audit reader via canopy-cli (delegated::SECURITY_GET_SECURITY_SUMMARY)
Query parameters: days (optional) — trailing window over created_at; defaults to 30, clamped to a 366-day cap. The window is mandatory server-side (#1229): there is no unbounded full-table aggregate path, and the query rides the idx_audit_events_created_at_id range with a statement timeout so an abandoned client cannot leave the aggregate running on the audit-ingest DB.
Response (200): Array of AuditSummaryRow objects (source_service, action, count) for events in the window.
audit_events rows only — a window wider than the operator-set archive
age threshold undercounts by design (archived rows are excluded).
Chain Verification (/v1/security/chain/*)
The unified chain-verification namespace (#1205, ADR-014 Amendment 9; the archived
chain-v2 verifiers plan): ONE
namespace, four endpoints. The FTI (Pub 1075) chains of canopy-tanf and
canopy-medicaid are served by the SAME four endpoints via
family=fti&service=….
Dormancy: the background verifiers run only when
CANOPY_SECURITY__CHAIN_V2_VERIFY_ENABLED=true (default false —
Configuration Reference). Because chain-v2 is withdrawn (ADR-041; ADR-014 Amendment 12),
along with the #1279 cutover that was to provision the LOGIN carriers, the
verify-pool URLs and the flag, the verifiers stay dormant until #1304
retires them.
Each family is dormant or live independently: the audit family follows
the flag + its verify-pool URL, and each FTI family (#1206) follows the
flag + its own CHAIN_VERIFY_TANF_DATABASE_URL / …MEDICAID… — one
program DB outage degrades that family only. While a family is dormant:
GET …/chain/status reports unknown with reason verifier_disabled → 503
(the #1245 fail-closed posture, preserved by status code), and
POST …/chain/verify + GET …/chain/attest return 503
verifier_unavailable (no job is ever queued for an unconfigured target).
One exception outranks dormancy on the fti arm: a latched legacy v1
breach row forces state: "breached" with reason legacy_breach_latched
(the #1245 "a breach is never silently swallowed" posture, Pub 1075 §9
reportable; retires with the fti_chain_verifications table when #1304
retires the chain — the #1279 drop was withdrawn).
Wire DTOs: crates/canopy-contracts-security/src/chain.rs — every closed
vocabulary is a real enum with its wire strings test-pinned. CLI parity
(ADR-007): canopy security chain-status / chain-verify / chain-attest.
GET /v1/security/chain/status
Verification status for one family target (ADR-014 Amendment 8).
- Access
-
system;
admin; worker reader via canopy-web, canopy-cli (delegated::SECURITY_GET_SECURITY_CHAIN_STATUS)
Query parameters:
| Parameter | Type | Description |
|---|---|---|
|
enum |
|
|
enum |
FTI service ( |
Response (200 or 503): ChainStatusResponse — the SAME typed body on
both codes. HTTP mapping: healthy/verifying → 200;
unknown/stale/error/breached → 503, so a consumer reading only the
status code fails closed while a typed consumer still gets the full picture.
The body carries state (the six-state machine), reasons[] (every firing
derivation input — the closed StatusReason vocabulary), epoch, per-shard
coverage (shards[]: tail verified-through / head / lag / stamps + scrub
cursor / target / cycle stamps), backlog (audit family only —
staged / parked / inbox-parked / DLQ depth; null for fti, typed
applicability), trusted_manifest (the verifier-checked anchor: id / seq /
age), and — on breached — the oldest unresolved incident_id plus its
typed breached_position.
POST /v1/security/chain/verify
Enqueue a durable manual verification job — never a synchronous walk (the #1245 OOM class stays dead). Jobs are token-claimed, target-scoped, and crash-safe: the work definition (instance / epoch / per-shard targets) is captured once at first claim, a reclaim resumes the SAME vector, and coverage is all-or-nothing. ONE active job per target (family, or family + service); manual runs never feed the status machine in either direction.
- Access
-
system;
admin(SERVICE_OR_ADMIN)
Request: ChainVerifyRequest
{"family": "audit", "loop": "family-full"}
loop ∈ {tail, scrub, family-full}, default family-full (tail + scrub
census + manifest). service is required exactly for family=fti.
incident_id (optional) marks a revalidation job for the
incident-resolution runbook
(Security Operations): it bypasses the family
halt gate and must run the incident’s DETECTED loop (or family-full).
Response (202): ChainVerifyJobAccepted — {job_id, poll_url}.
Response (409): verification_in_progress — an active job already
exists for the target; the body carries its job_id (idempotent — the
caller learns the in-flight id, no duplicate work). The enqueue reads the
active target under its lock and before the queue cap (#2659), so a
same-target request at the cap, including one that raced the request that
created the job, gets this 409, never the cap’s 503.
Response (503): verifier_unavailable — queue at
CHAIN_JOB_MAX_QUEUED for a target with no active job, verifier disabled,
or family unconfigured.
GET /v1/security/chain/verify-jobs/{id}
Poll one verify job. Requester-scoped: a system caller sees only the
jobs its client id requested; an admin sees all; an unknown or foreign id
returns 404 (existence is not disclosed across requesters).
- Access
-
system;
admin(SERVICE_OR_ADMIN)
Response (200): ChainVerifyJobStatus — state ∈
{queued, running, done, error}, requested_loop, attempts (reclaims
increment), the finalizing run summary once done, and error_code ∈
{coverage_incomplete, verifier_error, integrity_rejected, crashed} once
error.
GET /v1/security/chain/attest
Per-event verification attestation — the citation-PDF input ("Cite for hearing" refuses to issue without it).
- Access
-
system;
admin; audit reader via canopy-web, canopy-cli (delegated::SECURITY_GET_SECURITY_CHAIN_ATTEST)
Query parameters: event_id (uuid, required), family, service (same
rules as status).
Response (200): ChainAttestation. attested: true iff the position is
found (view-mediated, indexed, across archive ∪ live), the row’s
(instance, epoch) match the ACTIVE topology, seq sits within BOTH the
shard’s tail verified_through AND the trusted (verifier-checked) manifest
tip, and the family state is attestable (healthy/verifying). Otherwise
attested: false with reason ∈ {unknown_event, newer_than_checkpoint,
beyond_trusted_manifest, state_not_attestable, verifier_unavailable,
foreign_topology}.
Request-error matrix
The closed request-error vocabulary (each row is a named test; this table is the doc source of truth):
| Condition | Status | error code |
|---|---|---|
|
400 |
|
|
400 |
|
|
400 |
|
|
400 |
|
|
400 |
|
|
400 |
|
|
404 |
|
active job exists for the target (verify) |
409 |
|
queue at |
503 |
|
Archive Management
The async, durable archival protocol (#1208, plan
audit-archive-async) — the chain-verify-jobs
pattern applied to archival. It replaced the #1245 interim 503 (the unbounded
one-transaction mover was deleted for its OOM hazard, genesis-breaking boundary,
and ON CONFLICT DO NOTHING silent loss; this protocol is its structural fix:
per-chunk committed transactions, an inserted == deleted loss-proof assertion,
and a chain-head exclusion guard). A durable audit_archive_runs row is the unit
of work AND the accountability record; the always-spawned in-service runner
services it asynchronously. Operator procedures:
Security Operations › Archive Management.
POST /v1/security/archive
Enqueue a durable archive run — never executes inline. The run moves rows
whose received_at is older than the requested age threshold (cutoff computed
by the database clock) from audit_events to audit_events_archive in bounded,
per-chunk-committed transactions, always retaining the chain-head row.
- Access
-
admin(inlineAdmission::user_roles(&["admin"]), #1427): a system caller is 403service_class_on_user_only. The run row recordsrequested_by = admin:{subject}, the caller’s canopy subject (scheduled runs recordscheduler), so the requester is a person.
Request: ArchiveRequest
{"archive_after_days": 2555}
archive_after_days is an age threshold, not a retention value — the
archive retains rows indefinitely, so archiving early shortens nothing
(retention policy — floors, legal hold, purge — is #1303). Sanity domain
1..=36500; outside it → 400.
Response (202): ArchiveRunAccepted — {run_id, poll_url}; the Location
header carries the poll URL.
Response (400): archive_after_days outside 1..=36500.
Response (403): a system caller (service_class_on_user_only), the portal (portal_on_non_portal_route), or a user without admin (required_role_missing).
Response (409): an archive run is already queued or running — ONE active
run total. The body carries that run’s ArchiveRunAccepted handle (no
Location header): the caller learns the in-flight id, no duplicate work.
Response (503): database pool exhausted — retry later.
Idempotency: the run row is durable, so a replay under the same
Idempotency-Key returns the stored handle (no transient-409 class exists).
Use a fresh key per continuation run — e.g. when re-POSTing after a
more: true outcome to drain a backlog.
GET /v1/security/archive-runs/{id}
Poll one archive run.
- Access
-
system;
admin(SERVICE_OR_ADMIN)
Response (200): ArchiveRunStatus — the durable run row projected onto the
wire: run_id, state ∈ {queued, running, done, error}, requested_by
(admin:{sub} or scheduler), requested_at, the frozen config snapshot
(archive_after_days, chunk_size, max_chunks_per_pass), attempts
(lease-expiry reclaims increment; the ladder finalizes error/crashed with
progress intact), the per-chunk committed progress (chunks_committed,
rows_archived — durable and pollable mid-run and after a crash), more,
error_code/error_detail once error, and started_at/finished_at.
error_code is the closed set {duplicate_overlap, upgrade_state_unrepaired,
statement_timeout, db_error, crashed} — each maps to a runbook procedure
(Security Operations).
more semantics (set at done): the pass ended on a full chunk, so more
movable rows may remain (this coexists with the retained chain head — more
is about the chunk budget, not the head). more: true also pulls the
scheduler’s next due time forward to the catch-up cadence, so backlogs drain
without operator action.
Response (404): unknown archive run.
GET /v1/security/archive
One keyset page of archived audit events, newest first.
- Access
-
system;
admin(SERVICE_OR_ADMIN)
Query parameters:
| Parameter | Type | Description |
|---|---|---|
|
integer |
Page size, domain |
|
date-time |
Keyset cursor half — pair with |
|
uuid |
The other keyset cursor half. |
Response (200): Array of AuditEvent objects, ORDER BY received_at DESC,
id DESC. Page 2 = pass the last row’s (received_at, id) as the cursor.
Response (400): limit out of domain, or a lone cursor half (validated before the query — negative paging can never reach PostgreSQL).
offset,
source_service, event_type, action, household_id) are removed
(#1208) — they were advertised but ignored, and filters over an
unboundedly-growing archive without per-filter indexes recreate the O(n) trap.
Windowed historical needs ride the FOIA export union
(GET /v1/export/audit-events).
Export
GET /v1/export/audit-events
Bulk export of the audit log — one of the three cross-service FOIA / audit export surfaces described in the data-export runbook.
- Access
-
adminorquality_control(inlineAdmission::user_roles(&["admin", "quality_control"]),api/export.rs; #1427): a bulk PII egress with no system arm, so a system caller is 403service_class_on_user_only. The export’saudit.export.requestedevent records the caller’s canopy subject asactor.
Query parameters:
| Parameter | Type | Description |
|---|---|---|
|
date-time |
Inclusive start of the export window (RFC 3339 / ISO 8601). Defaults to 24 hours before |
|
date-time |
Exclusive end of the export window. Defaults to "now" if absent. |
|
string |
Output format: |
|
integer |
Row cap, default 10 000, hard cap 50 000. |
|
string[] (repeated) |
Same program-scope visibility predicate as |
Response (200): Audit events within the requested window (JSON array of AuditEvent, or CSV per format). The export reads archive ∪ live (#1208): a UNION ALL over the twin tables with explicit columns, ordered event_timestamp ASC, id ASC — the window spans the archive seam without truncation.
Response (400): Invalid time window or limit.
Response (403): a system caller (service_class_on_user_only), the portal (portal_on_non_portal_route), or a user holding neither role (required_role_missing).
Signing-key registry (#687, ADR-036)
The durable verification-key history behind the ES256 determination
signatures (ADR-002): each program service registers its current public
key on boot, and the orchestrator’s verifier lazy-loads a historical kid
from the per-program JWKS on a cache miss. Wire DTOs:
canopy_contracts_security::signing_keys (RegisterSigningKeyRequest,
Jwks, JwkKey). Rotation procedure: Signing Key Rotation.
POST /v1/security/signing-keys
Register (idempotently) a program’s current signing public key.
signing_authz::authorize_registration resolves the program, checks that
the system caller’s client id may sign for it, validates the SPKI key
and derives the canonical key-bound kid — a caller-supplied kid that
does not match the key is rejected.
- Access
-
system (inline
Admission::system()): a user is 403system_caller_required. Each program service registers on boot under its system token (crates/canopy-api/src/signing_registration.rs); the row records the caller’s client id.
Request: RegisterSigningKeyRequest — program (slug: snap, tanf, medicaid, caps, wic), kid, public_key_pem.
Response (204): registered, or already present. 400: unknown program, invalid public key, or a kid that does not match the submitted key. 403: the admission’s refusal, or a client not authorized to sign for that program (no code).
GET /v1/security/signing-keys/{program}/jwks
The program’s retained verification keys as a JWK Set.
- Access
-
system (inline
Admission::system()): a user is 403system_caller_required. canopy-eligibility’s verifier reads it under its system token (services/canopy-eligibility/src/key_history.rs).
Response (200): Jwks — keys[] of JwkKey (kty: EC, crv: P-256, x, y, kid, alg: ES256, use: sig). 400: unknown program. 403: the admission’s refusal.
canopy-identity JWKS (ADR-049 §9, #2500)
The public signing keys of canopy-identity, the module of canopy-security
that is the one issuer of internal tokens
(ADR-049). Each replica holds
its ES256 keys in memory only and publishes their public halves into the
registry (identity_signing_keys, identity_key_revocations:
data model). Receivers verify against
this set, read from that registry, never from a replica’s own copy;
canopy-security’s own receiver reads the memo below in process. The token
endpoint below mints the tokens they verify. Source:
services/canopy-security/src/identity/jwks.rs.
GET /identity/jwks
Mounted at the router root, outside /v1 and outside the OpenAPI document
(whose paths are relative to /v1), through canopy_api::ApiServer::router's
public_routes. It gets the outer layers (the security and API-Version
headers, CORS, compression, trace, the access log and the body limit) but not
the identity receiver, the idempotency layer or the per-IP rate limiter. The
memo below keeps at most one registry read in flight per replica, and one per
5 s while reads succeed, whatever the request rate.
- Access
-
public and unauthenticated; a bearer, if sent, is not read
- Source
-
the registry, read through the issuer pool (
canopy_identity_issuer,CANOPY_SECURITY__IDENTITY_DATABASE_URL), never the main pool
Response (200): Jwks — keys[] of JwkKey (kty: EC, crv: P-256,
x, y, kid, alg: ES256, use: sig); the kid is the key’s RFC 7638
thumbprint. The keys are the registry rows the database clock publishes
(created_at ⇐ now() < publish_until) with no revocation, newest first, at
most 64 (about 13 KiB, under canopy-auth’s 64 KiB JWKS body cap). A row whose
coordinates are not a P-256 point is left out, with a warning log. An empty
registry answers {"keys": []}.
-
Cache-Control: no-cache. -
Age(RFC 9111 §5.1): the whole seconds since this replica sent the read the set came from. Each replica memoizes one read for up to 5 s, single-flight: requests that find it older share one read. A receiver measures the set’s staleness from the read, its request start minusAge; ADR-049’s 300 s refresh and 720 s fail-closed bounds are stated against that measure.
Response (503): the registry read failed or did not finish within 11 s
(problem detail the signing keys are unavailable). An older set is never
served in its place, and the requests waiting on the failed read share its
503.
canopy-identity token endpoint (ADR-049 §2, §3, §6, §7, #2554, #2716, #2717, #2718, #2724, #2746, #2747, #2748, #2749)
canopy-identity’s token endpoint, its revocation endpoint and its RFC 8414
metadata (ADR-049 Amendment 3,
Amendment 6 and Amendment 7). The
token endpoint serves client credentials, which mints system tokens, and
RFC 8693 token exchange in two families: the federation grant, by which
canopy-web opens a web session from an upstream id_token, renews it, and
may hold it under a bounded grace, and approves a device for canopy-cli,
opening a native session it renews the same way (Amendment 9); the native grants, by which canopy-cli redeems an approved device
with a DPoP proof of its key and rotates the refresh credential it was
given; and the delegation mint, by which
canopy-web mints a per-target delegation token from a web session, and a
service mints one onward from a delegation token addressed to it. The
revocation endpoint lets canopy-web revoke its own sessions (RFC 7009). All
three routes are mounted like the JWKS, through public_routes, outside
/v1, the OpenAPI document, the identity receiver and the service’s own
limiter. Source:
services/canopy-security/src/identity/token_endpoint.rs,
token_endpoint/federation.rs, token_endpoint/federation/renewal.rs,
token_endpoint/federation/approval.rs, token_endpoint/delegation.rs,
token_endpoint/native.rs, token_endpoint/native/redemption.rs,
token_endpoint/native/refresh.rs,
token_endpoint/revocation.rs and token_endpoint/device.rs.
POST /identity/token
Grants a system token for one named purpose (client credentials), opens
or renews a canopy web session for canopy-web, approves a device and
renews the native session it opens, or mints a delegation
token from one, for canopy-web, or onward from a delegation token, for a
service (token exchange), to a client that authenticates
with a private_key_jwt assertion (RFC 7523 §2.2); and redeems an
approved device, then rotates its refresh credential, for canopy-cli, a
public client proving its device key by a DPoP proof (the native
grants).
- Access
-
public; a confidential client authenticates in the form (an assertion signed by a key the client registry binds to an enabled client,
identity-clients.yaml, configuration reference); canopy-cli, a public client, sends no assertion and proves its device key by aDPoPproof (the native grants) - Rate limit
-
IDENTITY_TOKEN_RATE_LIMIT_RPMrequests a minute per IP (30 000 by default,canopy_api::apply_rate_limit; ADR-049 Amendment 10), one limiter shared withPOST /identity/revokeandPOST /identity/device_verification; a request it refuses is a 429 that never reaches the handler and is not logged. Each client also has a per-replica budget of token requests, its registry entry’srate_limit_rpm(6 000 a minute by default, configuration reference): every request of client credentials or the token exchange spends one right after its client authenticates, and one past it is a 429temporarily_unavailablewithRetry-After(whole seconds), logged asclient_rate_limitedbefore its form is judged. canopy-cli’s budget isIDENTITY_NATIVE_RATE_LIMIT_RPM: a device code poll spends one once its device is found and it is not told to slow down, a refresh once its credential is found bound to the proof’s key, a 429 likewise past it.POST /identity/revokespends none - Budget
-
the body is read within 2 s, before the grant is known. Client credentials: 5 s per request, 2 s to read the body, authenticate and mint, and up to 3 s for the issuance-log commit. Token exchange: one absolute deadline 13 s from the start (
canopy_auth::TOKEN_EXCHANGE_DEADLINE): the client authenticated, and a renewal’s session read and a native renewal’s unredeemed rule asked, by 2.5 s; at most three upstream calls (discovery, JWKS, userinfo), each bounded by the upstream client’s 2.5 s, so they end by 10 s; then the 3 s reserve, in which the session’s transaction (an open’s, an approval’s, a renewal’s, a grace’s or a revocation’s) runs to 11.5 s (TOKEN_EXCHANGE_TRANSACTION_END) and the last 1.5 s are kept for a refusal’s log row, a transaction that never answered included. A delegation: its body, client, onward subject token, session read and signing by 2.5 s, and its issuance-log row within 3 s more, 5.5 s in all (canopy_auth::DELEGATION_BUDGET); no upstream call. A native grant, a device code’s redemption or a refresh: its body, proof, credential,jti, session read and signing by 2.5 s, the store’s transaction by 4.5 s (NATIVE_TRANSACTION_END), and a refusal’s row by 5.5 s (canopy_auth::NATIVE_BUDGET); no upstream call. A refusal of a form that named no grant is audited within the client-credentials budget.
Request (application/x-www-form-urlencoded, at most 64 KiB, room for every decoded cap below at once with the access token’s every byte percent-encoded). Client credentials and the token exchange carry grant_type, client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer, client_assertion (the compact JWS) and optionally client_id (which must name the assertion’s client, RFC 7521 §4.2); the native grants carry no assertion (below). A parameter without a value counts as omitted, an unrecognized one is ignored, and a recognized one (of any grant) sent twice, or holding a control character, refuses the form (RFC 6749 §3.2).
-
Client credentials:
grant_type=client_credentials, exactly oneresource(an RFC 8707 audience URI,urn:canopy:service:<service-name>), and optionallyscope(space-separated). -
Token exchange (
grant_type=urn:ietf:params:oauth:grant-type:token-exchange), served whenever the issuer is configured. After the client authenticates, the form is identified byrequested_token_type, thensubject_token_type; a client the form does not admit isunauthorized_clientbefore its other parameters are judged.scope,audience,actor_tokenandactor_token_typeare refused in every form. -
The federation forms,
requested_token_type=urn:canopy:params:oauth:token-type:web-session, canopy-web only, served only when an upstream profile is configured (the federation grant; without one,federation_unconfigured).resource,requested_rolesandrequested_programsare refused.-
Open:
subject_token= the upstream id_token (at most 16 KiB decoded),subject_token_type=urn:ietf:params:oauth:token-type:id_token, andupstream_access_token(at most 8 KiB decoded) exactly when the profile’s claims come from userinfo. The renewal’supstream_id_tokenandupstream_outcomeare refused. -
Renew:
subject_token= the session credential (exactly 43 canonical base64url characters),subject_token_type=urn:canopy:params:oauth:token-type:web-session, and exactly one piece of evidence:upstream_id_token= the refreshed id_token (at most 16 KiB decoded) underrefresh: reissues_id_token;upstream_access_token= the upstream access token (at most 8 KiB decoded) underrefresh: userinfo; orupstream_outcome=not_processed, under either, when canopy-web could not process the upstream’s refresh. No evidence, more than one, a token the profile’srefreshdoes not name, or anotherupstream_outcomerefuses the form.
-
-
The native forms,
requested_token_type=urn:canopy:params:oauth:token-type:native-revalidation, canopy-web only, served only when an upstream profile is configured (elsefederation_unconfigured; device approval).resource,requested_rolesandrequested_programsare refused.-
Approve a device: an open’s parameters, from the worker’s step-up sign-in:
subject_token= the id_token,subject_token_type=urn:ietf:params:oauth:token-type:id_token, andupstream_access_tokenexactly when the profile’s claims come from userinfo;user_code= the device’s user code as the worker typed it, read only after the worker’s attempt is spent; andweb_session= the approving worker’s web-session credential (ADR-049 Amendment 21). The renewal’supstream_id_tokenandupstream_outcomeare refused. -
Renew: a web renewal’s parameters, with
subject_token= the native session’s revalidation credential andsubject_token_type=urn:canopy:params:oauth:token-type:native-revalidation.A
user_codeor aweb_sessionon any form but an approval is refused (parameter_refused). Each kind of session renews only by its own token type, and the revalidation type is no delegation’s subject (subject_token_type_unsupported); a revalidation credential sent under the web-session type names no web session (session_ended).
-
-
The delegation forms,
requested_token_type=urn:ietf:params:oauth:token-type:access_token, with or without an upstream profile, each with exactly oneresourcenaming a compiled receiver (urn:canopy:service:<service-name>) and optionallyrequested_rolesandrequested_programs(space-separated values in any order, role names^[a-z_]{1,64}$and program wire ids, each once). Everyupstream_*parameter is refused.-
From a session:
subject_token= a web-session credential (exactly 43 canonical base64url characters),subject_token_type=urn:canopy:params:oauth:token-type:web-session; canopy-web only. -
Onward:
subject_token= a delegation token addressed to the client’s own service (at most 8 KiB),subject_token_type=urn:ietf:params:oauth:token-type:access_token; a confidential client that runs as a service only (neither canopy-web nor the portal).
-
-
The device code grant (RFC 8628 §3.4),
grant_type=urn:ietf:params:oauth:grant-type:device_code, with or without an upstream profile:device_code,client_id=canopy-cli(a public client), exactly oneresourceand optionallyrequested_rolesandrequested_programs, with exactly oneDPoPrequest header (RFC 9449): a proof by canopy-cli’s device key forPOSTto the public token endpoint ({issuer}/token, not the internal URL), read before the body.client_assertion,client_assertion_typeandscopeare refused (parameter_refused). ADPoPheader is ignored by every other grant. -
The refresh grant (RFC 6749 §6),
grant_type=refresh_token, with or without an upstream profile:refresh_token= canopy-cli’s refresh credential (43 characters of unpadded base64url),client_id=canopy-cli, exactly oneresourceand optionallyrequested_rolesandrequested_programs, with exactly oneDPoPheader, refused and ignored as for the device code grant.
The assertion (identity/client_auth.rs): at most 8 KiB; a protected header of exactly alg = ES256, kid and an optional typ, which must name client-authentication+jwt; a kid that is the RFC 7638 thumbprint of an enabled client’s registered key; iss = sub = that client; aud exactly the issuer identifier; iat at most 60 s ahead; exp after now, at most 60 s after iat; a jti of 1 to 128 characters, accepted once per client (the jti store, data model).
Once the assertion verifies, and before its jti is spent, its client must not be disabled at runtime by a security administrator (ADR-049 Amendment 8, identity/client_status.rs): one that is is invalid_client, logged client_disabled, its jti unspent; a client status that does not answer is 503 temporarily_unavailable, logged client_status_unavailable. Each replica reads the disablements through the issuer pool into a memo it serves for under 5 s, never serving an older read after a failed one, so a disablement holds on every replica from 5 s after it commits; tokens already minted stay valid to their exp. A client the registry does not enable stays refused whatever its runtime state. The same check guards POST /identity/revoke.
The client-credentials flow: authenticate the client, derive the purpose from the client and resource (canopy_auth::purpose_for), check scope against the purpose’s set (absent: the full set), take this replica’s active key, and mint the token. The answer, success or refusal, is released only after its identity_issuance_log row commits.
The token-exchange flow, in order: authenticate the client; refuse any client but canopy-web (unauthorized_client) before any lookup; refuse the form without an upstream profile (invalid_request, federation_unconfigured); judge the exchange parameters against the profile; verify the id_token; for userinfo claims, call userinfo with the forwarded token, bound to the id_token’s sub; project the claims; fix the session’s terms (it ends at auth_time + identity_web_session_max_seconds and is fresh until the id_token’s iat + 900 s; an end under 900 s away refuses); and open the session in one transaction that links or mints the canopy subject, checks its suspension, stores the session (the credential only as its SHA-256) with its version 1 validation, and commits its opened issuance-log row (the session store). The credential is released only after that commit. A refusal is logged before it is answered, naming the canopy subject when the open reached one.
The renewal flow, after the same client, profile and form checks: read the session by the credential’s hash, as canopy-web opened it, by 2.5 s; an unknown, revoked or ended session answers session_ended. A profile whose issuer or client_id is not the session’s revokes it (upstream_changed) before any upstream call, and answers session_ended. Then the evidence: a refreshed id_token is verified, then must carry the session’s iss, sub and original auth_time, the original nonce or none, and an iat newer than the latest recorded, unless it is that latest id_token again (a replay); its claims are projected. An access token is sent to userinfo bound to the session’s stored upstream sub, and the answer projected. not_processed asks for the grace. The result is recorded with the version the session read had, in the reserve, by the transaction end: a projection as the session’s next validation, fresh until its instant (the id_token’s iat, or userinfo’s arrival) + 900 s, taking the new roles and programs either way; a grace as a copy of the latest successful validation, fresh until that instant + 900 s + identity_session_grace_seconds, never extended by a second grace; each with its renewed or grace issuance-log row in the same transaction (the session store). A renewal that finds a later version committed is superseded and answers that state; a replay answers the current one. The outcomes:
| Renewal outcome | Answer | The session |
|---|---|---|
a projection recorded; a replay; a superseded renewal |
200, the token-exchange body (the credential echoed) from the state recorded or found |
renewed; unchanged; as the later version left it |
userinfo or the key fetch unavailable; |
200, the token-exchange body: the grace |
held under the grace |
userinfo refused the access token, or answered invalidly by the upstream’s own doing (a Refused answer, and an Invalid answer’s status, media type, size, body and subject classes) |
|
revoked ( |
the claims project to nothing canopy grants |
|
revoked ( |
the profile names another issuer or client |
|
revoked ( |
the subject is suspended |
|
revoked ( |
the refreshed id_token refused, mismatched or not newer; an access token userinfo will not send |
|
unchanged, to lapse at its |
userinfo’s endpoint missing or refused by the client (the deployment’s defect, logged at warn) |
|
unchanged, to lapse at its |
a grace asked for once its window has passed |
|
unchanged |
an unknown, ended or revoked session |
|
unchanged |
A native session renews by the same flow, its revalidation credential read only among native sessions; first, by 2.5 s, before any upstream call, one approved but never redeemed when its device code expired is revoked (unredeemed) with its refused row, answering session_ended.
The approval flow, after the same client, profile and form checks: verify the step-up id_token and project its claims as an open does; refuse a sign-in more than 600 s old (auth_time_too_old, canopy_auth::DEVICE_APPROVAL_MAX_AGE_SECONDS, the step-up bound); read the approving worker’s web session as code entry does, live, fresh and unsuspended, else session_ended, session_stale or subject_suspended (the last naming the subject; Amendment 21); spend one of the worker’s attempts, the per-replica budget POST /identity/device_verification spends, keyed by the id_token’s issuer and subject as the worker’s web sessions store them, a 429 past it; read the user code, refusing a malformed one, and refuse it while canopy-cli is disabled (device_client_disabled); then, in one transaction by the transaction end, link or mint the canopy subject, refuse one other than the web session’s (approver_mismatch), open the native session and record the device’s approval naming it, with its opened issuance-log row naming the device (the native store). The session’s opener is canopy-cli, its credential the revalidation credential (stored as its SHA-256), and it ends identity_native_session_max_seconds after the sign-in (default 8 h); it is fresh until the id_token’s iat + 900 s. An unknown, expired or decided device (user_code_unknown, user_code_expired, user_code_decided), a suspended subject, or a subject other than the approving web session’s rolls all of it back, so a refused approval keeps no subject, session or decision, and the device stays pending for its own worker. The revalidation credential is released only after the commit; canopy-web alone presents it, to renew the session, and it mints nothing.
A refusal that revoked the session commits its refused revoked row in the revocation’s own transaction; every other refusal is logged before it is answered, naming the session and its subject once the read found them. Every refusal leaves a session it did not revoke exactly as it was: a lapse after a grace keeps the grace’s fresh_until.
The device code flow, in order: refuse any client_id but canopy-cli (client_not_native) and a disabled canopy-cli (client_disabled); refuse a resource that names no receiver or one canopy-cli has no delegation edge to, and a malformed narrowing; verify the one proof (header exactly typ: dpop+jwt, alg: ES256 and an EC P-256 jwk; claims exactly jti, htm: POST, htu, iat; the signature under the embedded key; htu the public token endpoint after normalization; iat within 60 s; at most 2 KiB), each refusal invalid_dpop_proof under the proof’s reason (dpop_missing, dpop_several, dpop_target, …); find the device by the code’s hash (none: invalid_grant, device_code_unknown); answer a poll under 5 s after the device’s last answered one slow_down, per replica, changing nothing; spend canopy-cli’s budget (IDENTITY_NATIVE_RATE_LIMIT_RPM, a 429 past it) and the proof’s jti, once per key across replicas until its iat + 120 s (a replay: invalid_dpop_proof, dpop_replayed); then answer the device as it stands: undecided, authorization_pending, or expired_token once its codes have expired; denied, access_denied. An approved device’s session is read and judged as a delegation’s (session freshness gates every native mint), each refusal invalid_grant with canopy_refusal session_ended, subject_suspended or session_stale; the token is minted as a delegation from it, its act canopy-cli alone, its sets the session’s or narrower, its exp the least of 300 s and the session’s end, signed by 2.5 s. The store then redeems the code in one transaction: under the session’s lock it rechecks the device and the session, and inserts refresh credential version 1, bound to the proof’s RFC 7638 thumbprint, with the token’s device_code issuance-log row naming the device and version 1 (the native store). The token and the credential are released only after that commit. A code already redeemed revokes its session (device_code_reused, answered invalid_grant with session_ended), the store committing that refused row with the revocation; every other refusal is logged before it is answered, naming the device and the session once found.
The refresh flow shares the device code flow’s first steps: canopy-cli named and enabled; the target and narrowing judged; the one proof verified. Then the refresh credential is found by its hash, any version (none: invalid_grant, refresh_unknown), and must be bound to the proof’s key, the RFC 7638 thumbprint every version of the session’s credential carries: another key is invalid_grant (dpop_key_mismatch), before anything is spent, and revokes nothing, since the credential alone mints nothing. canopy-cli’s budget and the proof’s jti are spent; the token is minted from the native session as at redemption, the session’s freshness gating it (a stale session session_stale: canopy-web renews it), its narrowing narrowing the token alone, never the session. The store then rotates the credential under the session’s lock: the presented version, the latest, is succeeded by the next, bound to the same key, with the token’s refresh_token issuance-log row naming the version. A superseded version presented under its key revokes the session (refresh_reused, answered invalid_grant with session_ended; strict reuse detection, RFC 9700 §4.14.2), the store committing that refused row with the revocation. The token and the successor are released only after the rotation commits; a rotation whose row the log refuses, or which misses its 4.5 s, rolls back, and the same version may be presented again.
The delegation flow, in order: authenticate the client; refuse a client the form does not admit (unauthorized_client); judge the form, its narrowing included; refuse a resource that is no receiver, or a target the client has no delegation edge to, as invalid_target; then read the session, by the credential’s hash among canopy-web’s: no session, a revocation or an end that has passed answers session_ended, a suspended subject subject_suspended, a freshness that has passed session_stale (canopy-web renews, then retries). The token’s roles and programs are the session’s current ones, or the requested ones when they lie within them (wider, or an empty base, is invalid_scope); its exp is the least of iat + 300 s and the session’s end, refused under 5 s as session_ended. It is signed with this replica’s active key and released only after its delegated issuance-log row commits, naming the token, the session, its subject and the sets; expires_in is counted then, and a token with under a second left, after a wall-clock step, is a 503 that releases nothing.
The onward flow runs the same steps with a client that runs as a service, and between the target and the session two more: the subject token is verified in process against the published keys (the JWKS memo, identity/key_source.rs), as a receiver of the client’s own service would verify it (canopy_auth::IdentityTokenValidator: the JWS, iss, aud the client’s service, a lifetime of 1–300 s, the times within 60 s, and its current actor holding a delegation edge to the client), by 2.5 s; a key set that is unavailable, or has not answered by then, is a 503. The client is then added to the subject token’s act chain, refused if it already acts in it or the chain would pass eight actors. The session is read by the subject token’s sid and judged as above, its opener the chain’s innermost actor and its subject the token’s sub (else subject_session_mismatch). The token’s base sets are the subject token’s within the session’s current ones; its exp is also no later than the subject token’s, a subject expiring within 5 s, or already past its exp within the 60 s leeway, being subject_expiring. Its row names the subject token’s jti (subject_token_jti), so a chain’s rows link hop to hop; a refusal after the subject token verifies names it too.
Response (200, client credentials): {access_token, token_type: "Bearer", expires_in: 600, scope}. The token is a JWS with the header typ: at+jwt, alg: ES256 and the signing key’s kid, and the claims iss sub aud exp iat nbf jti client_id purpose scope (sub = client_id, nbf = iat, aud the resource, lifetime 600 s; canopy_auth::SystemTokenClaims).
Response (200, token exchange; RFC 8693 §2.2.1), an open’s, an approval’s or a renewal’s; a renewal echoes the credential it presented, which is never rotated:
| Field | Type | Value |
|---|---|---|
|
string |
the session credential, a native session’s revalidation credential: 43 characters of unpadded base64url, opaque, never a JWT |
|
string |
|
|
string |
|
|
integer |
seconds to |
|
string |
the session id (UUID) |
|
string |
the canopy subject (UUID), never the upstream |
|
integer |
the upstream authentication (NumericDate) |
|
integer |
when the session ends, whatever renews it (NumericDate) |
|
integer |
when the session stops being fresh unless renewed (NumericDate) |
|
string array |
the projected vocabulary roles |
|
string array |
the projected programs (wire ids) |
|
string |
the projected username |
Response (200, device code or refresh, RFC 6749 §5.1): {access_token, token_type: "Bearer", expires_in, refresh_token}, the refresh credential new at each answer. The access token is a delegation token as below, its act canopy-cli alone; it is a bearer, and only the refresh credential, 43 characters of unpadded base64url stored as its SHA-256, is bound to the proof’s key (RFC 9449 §5).
Response (200, delegation; RFC 8693 §2.2.1): {access_token, issued_token_type: "urn:ietf:params:oauth:token-type:access_token", token_type: "Bearer", expires_in}, with no refresh token and no scope. The token is a JWS with the header typ: at+jwt, alg: ES256 and the signing key’s kid, and the claims iss sub aud exp iat nbf jti client_id sid roles programs act auth_time (sub the canopy subject, sid the session, aud the resource, nbf = iat, act canopy-web alone from a session, and onward the client before the subject token’s chain, client_id the current actor; canopy_auth::DelegationTokenClaims).
Errors (RFC 6749 §5.2 JSON, {"error": …}, plus canopy_refusal on a token-exchange refusal its caller must act on; each logged with its own reason):
| Cause | error |
canopy_refusal |
Status |
|---|---|---|---|
a body that is not form-urlencoded, past 64 KiB, unreadable or malformed; a repeated parameter; a missing parameter; several |
|
400 |
|
|
|
400 |
|
a federation form with no upstream profile configured ( |
|
400 |
|
a wrong |
|
400 |
|
a federation form, or a delegation from a session, from any client but canopy-web; an onward delegation from a client that does not run as a service |
|
400 |
|
|
|
400 |
|
a delegation’s |
|
400 |
|
a delegation’s narrowing names a value outside its base, the session’s current sets, within the subject token’s onward ( |
|
400 |
|
an onward subject token refused by a receiver’s rule ( |
|
400 |
|
a delegation’s session is unknown, revoked, ended or ending within 5 s |
|
|
400 |
a delegation’s session is past its freshness |
|
|
400 |
a delegation’s subject is suspended |
|
|
400 |
|
|
400 |
|
a token-exchange form defect: a wrong |
|
400 |
|
the id_token refused by any id_token rule; a session end past the last NumericDate |
|
400 |
|
userinfo refused the access token, or answered with a status, media type, size, body or |
|
|
400 |
the forwarded access token is one userinfo will not send (longer than 8 KiB after the grammar’s cap, or not an RFC 6750 |
|
400 |
|
the claims project to nothing canopy grants |
|
|
400 |
the session would end under 900 s from now; an approval’s sign-in more than 600 s old |
|
|
400 |
an approval’s user code malformed, unknown, expired or decided, or canopy-cli disabled ( |
|
|
400 |
the canopy subject is suspended; at a renewal, the session is revoked |
|
|
400 |
an approval’s web session unknown, revoked, ended or past its freshness, or its subject suspended (Amendment 21) |
|
|
400 |
an approval’s step-up resolving to a subject other than its web session’s ( |
|
|
400 |
a renewal: the refreshed id_token refused by any id_token rule, carrying another |
|
400 |
|
a renewal: the claims project to nothing canopy grants (the session is revoked) |
|
the projection’s code |
400 |
a renewal: an unknown, ended or revoked session; the profile’s issuer or client no longer the session’s (the session is revoked); a native session approved but never redeemed by its device code’s expiry ( |
|
|
400 |
a renewal: a grace asked for once its window has passed |
|
|
400 |
a device code’s poll: undecided, its codes alive ( |
|
400 |
|
a device code no device holds, or no device code ( |
|
400 |
|
a superseded refresh credential presented under its key ( |
|
|
400 |
a device code redeemed already ( |
|
|
400 |
a native grant’s session: its subject suspended ( |
|
|
400 |
a native grant’s |
|
400 |
|
a native grant’s |
|
400 |
|
an authenticated client past its token-request budget ( |
|
429 |
|
the issuer unconfigured; the jti store unavailable (an error or a timeout, never read as a replay); no active key; a signing failure; the processing budget spent; the upstream’s keys or userinfo unavailable at an open (at a renewal they hold the session under its grace); no userinfo endpoint named anywhere, or one the client refuses (the deployment’s defect, logged as a misconfiguration; at a renewal, the session is left as it was); the session store unavailable, a renewal’s session read past the first phase or a transaction past the transaction end included; the published keys unavailable to verify an onward subject token, or unanswered by the first phase ( |
|
503 |
canopy_refusal is a closed set (canopy_auth::CanopyRefusal): the four projection codes, auth_time_too_old, subject_suspended, upstream_refused, grace_exhausted, session_ended, session_stale, user_code_invalid and Amendment 21’s approver_mismatch. invalid_client is a 400: the client authenticates in the form, not in an Authorization header, so RFC 6749’s 401 and its WWW-Authenticate challenge do not apply. A 503 releases nothing and carries no canopy_refusal. When the row of an answer cannot be committed, the endpoint makes one more attempt, within the budget, to log that refusal (audit_unavailable).
Every response of this route, a 429 included, carries Cache-Control: no-store and Pragma: no-cache (RFC 6749 §5.1), set by a layer outside the route’s limiter.
POST /identity/revoke
canopy-web revokes a web session it opened (RFC 7009), its sign-out, or a native session by its revalidation credential, its revoke-this-device; and canopy-cli revokes its own native session by its refresh credential, its logout. Served whenever the issuer is configured, with an upstream profile or without one, since a session outlives the profile it opened under. Source: token_endpoint/revocation.rs.
- Access
-
public; canopy-web authenticates in the form with a
private_key_jwtassertion, as atPOST /identity/token; canopy-cli, a public client, names itself byclient_idalone, with no assertion and no DPoP proof (the credential is the authority, and revoking only ends a session); no other client is served - Rate limit
-
the token route’s limiter, shared:
IDENTITY_TOKEN_RATE_LIMIT_RPMrequests a minute per IP; a 429 never reaches the handler and is not logged - Budget
-
5 s per request: 2 s to read the body, authenticate the client, read the session and revoke it (the revocation’s issuance-log row commits with it), and up to 3 s for any other answer’s issuance-log commit. Nothing here calls the upstream, and neither client’s token-request budget is spent.
Request (application/x-www-form-urlencoded, at most 64 KiB, read as the token route reads its body). canopy-web’s: client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer, client_assertion (held to the same rules as at the token route, its jti spent once), token = a session credential or a native session’s revalidation credential, and optionally client_id, which must name the assertion’s client. canopy-cli’s: client_id=canopy-cli and token = any version of its refresh credential, with neither assertion parameter; one of them without the other is a missing parameter. Either may send token_type_hint, which is ignored (RFC 7009 §2.1: each client revokes by its own kind of token). A parameter without a value counts as omitted, an unrecognized one is ignored, and a recognized one sent twice, or holding a control character, refuses the form.
canopy-web’s flow, in order: authenticate the client; refuse any client but canopy-web (unauthorized_client) before any lookup, so no other client learns whether a credential exists; read the session the token names by its SHA-256, a web session or, failing that, a native one by its revalidation credential; and, when the session is live, revoke it for logout in one transaction that also commits its revoked issuance-log row (the session store). canopy-cli’s flow: refuse any other public client (invalid_client, client_not_native) and a disabled canopy-cli (client_disabled); find the refresh credential the token is, any version, current or superseded, by its SHA-256, and read its native session; and, when that session is live, revoke it for logout by canopy-cli the same way. A revoked session is then refused at renewal and at every native grant (session_ended).
The token names |
Answer | Issuance-log row |
|---|---|---|
a live session the client may revoke: canopy-web’s web session, a native session by its revalidation credential, or canopy-cli’s native session by its refresh credential |
200, no body; the session is revoked ( |
|
no session, an ended one or a revoked one (a repeat included, or a revocation another request committed first); or it is no credential of the client’s kind at all |
200, no body; nothing is revoked |
|
The two 200s are the same on the wire, so a response never reveals whether a credential existed (RFC 7009 §2.2).
Errors (RFC 6749 §5.2 JSON, {"error": …}, never a canopy_refusal; each logged as a refused revocation row with its own reason, naming the session and its subject when the refusal knew them):
| Cause | error |
Status |
|---|---|---|
a body that is not form-urlencoded, past 64 KiB, unreadable or malformed; a repeated parameter; a missing or empty |
|
400 |
a wrong |
|
400 |
any authenticated client but canopy-web |
|
400 |
the issuer unconfigured; the jti store or the client status unavailable; the processing budget spent reading the body; the session store unavailable, a read or revocation past 2 s included (naming the session once the read found it); the revocation’s own row refused by the log, which rolls the revocation back; any answer’s row not committed |
|
503 |
A revocation whose row the log refused rolled back with it; one cut off at 2 s may still have committed, with its row, if its COMMIT reached the server first. Either way canopy-web retries, and a retry of a session already revoked answers 200. When the row of an answer cannot be committed, the endpoint makes one more attempt, within the budget, to log that refusal (audit_unavailable). Every response, a 429 included, carries Cache-Control: no-store and Pragma: no-cache.
POST /identity/device_authorization
canopy-cli starts a device flow (RFC 8628 §3.1; ADR-049 §7, Amendment 9; #2746). Served only with the issuer, an upstream profile and CANOPY_SECURITY__IDENTITY_DEVICE_VERIFICATION_URI all configured; otherwise 503 temporarily_unavailable, logged as device_flow_unconfigured (issuer_unconfigured without the issuer). Source: token_endpoint/device.rs.
- Access
-
public; canopy-cli is a public client, so the form carries no assertion
- Rate limit
-
its own limiter: 30 requests a minute per IP (
DEVICE_AUTHORIZATION_RATE_LIMIT_RPM; ADR-049 Amendment 10), since a device authorization creates a row from aclient_idalone; a 429 never reaches the handler and is not logged. canopy-cli’s own budget is not spent here; its polls spend it. - Budget
-
5 s per request: 2 s to read the body and store the flow (its
issuedrow commits with it), and up to 3 s for a refusal’s row.
Request (application/x-www-form-urlencoded, read as the token route reads its body): client_id=canopy-cli. scope, resource and a client assertion are refused (parameter_refused): a device authorization takes no target (the token is targeted at redemption), and a public client has no assertion. Any other parameter is ignored.
Response (200, RFC 8628 §3.2): {"device_code", "user_code", "verification_uri", "expires_in": 600, "interval": 5}. device_code is 43 base64url characters; user_code is eight symbols drawn from twenty consonants, shown XXXX-XXXX; verification_uri is the configured page. There is no verification_uri_complete (§5.4). The store draws another user code while the drawn one is held by a stored flow, at most three times, and commits the flow with its device_authorization, issued row naming the device.
Errors (RFC 6749 §5.2 JSON; each logged as a refused device_authorization row with its own reason, naming canopy-cli once the form is read):
| Cause | error |
Status |
|---|---|---|
a body that is not form-urlencoded, past 64 KiB, unreadable or malformed; a repeated parameter; a missing |
|
400 |
a |
|
400 |
the issuer, profile or page unconfigured ( |
|
503 |
Every response carries Cache-Control: no-store and Pragma: no-cache.
POST /identity/device_verification
canopy-web’s code entry for a worker (ADR-049 Amendment 9; #2746): describe names the device’s client and times for canopy-web’s approval screen, and deny records the worker’s denial. Served when the device flow is (above). Source: token_endpoint/device.rs.
- Access
-
public; the client authenticates in the form with a
private_key_jwtassertion, and only canopy-web is served - Rate limit
-
the token route’s limiter, shared; canopy-web’s per-replica budget; and the worker’s attempt budget: every describe, denial and approval spends one attempt of a per-replica budget keyed by the worker’s upstream issuer and subject, 10 at once and one more a minute (ADR-049 Amendment 9’s 10 per 10 minutes; at most 20 in any 10 minutes)
- Budget
-
5 s per request: 2 s to read the body, authenticate canopy-web and decide (a denial’s row commits with it), and up to 3 s for a description’s or a refusal’s row
Request (application/x-www-form-urlencoded): client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer, client_assertion, web_session = the worker’s web-session credential, user_code as the worker typed it (read case-insensitively, - and spaces ignored), action = describe or deny, and optionally client_id, which must name the assertion’s client.
The flow, in order: authenticate canopy-web and spend its budget, refusing any other client (unauthorized_client); read the worker’s web session, which must be live, its subject unsuspended and fresh; spend one of the worker’s attempts; read the user code; refuse it if canopy-cli is disabled; then describe or deny its device.
Response (200): for describe, {"client_id": "canopy-cli", "started_at", "expires_at"} in seconds since the epoch, after its device_verification, described row (naming the device and the worker’s session) commits; for deny, {}, the denial and its denied row committing together.
Errors (RFC 6749 §5.2 JSON, with canopy_refusal where canopy-web must act; each logged as a refused device_verification row with its own reason, naming the worker’s session and the device once known):
| Cause | error |
canopy_refusal |
Status |
|---|---|---|---|
a body defect, a repeated parameter, a missing parameter, an |
|
400 |
|
a credential that names no live web session (unknown, ended, revoked or malformed) |
|
|
400 |
the worker’s subject suspended |
|
|
400 |
the worker’s session past its freshness |
|
|
400 |
a user code that is malformed, unknown, expired or already decided, or whose client is disabled ( |
|
|
400 |
a wrong |
|
400 |
|
any authenticated client but canopy-web |
|
400 |
|
canopy-web past its budget ( |
|
429, with |
|
the device flow unconfigured; the jti store, client status, session store or device store unavailable; a row not committed |
|
503 |
Every response carries Cache-Control: no-store and Pragma: no-cache.
GET /.well-known/oauth-authorization-server/identity
The RFC 8414 §3.1 metadata document of the issuer <issuer> = …/identity.
- Access
-
public and unauthenticated
Response (200): issuer, token_endpoint ({issuer}/token), jwks_uri ({issuer}/jwks), grant_types_supported (["client_credentials", "urn:ietf:params:oauth:grant-type:token-exchange", "urn:ietf:params:oauth:grant-type:device_code", "refresh_token"], with or without an upstream profile, since a delegation is minted from a session, and a native grant from a native session, each of which outlives its profile), token_endpoint_auth_methods_supported: ["private_key_jwt", "none"] (none for canopy-cli, a public client proving its key by DPoP), token_endpoint_auth_signing_alg_values_supported: ["ES256"], revocation_endpoint ({issuer}/revoke, listed with or without an upstream profile, since a session outlives its profile), revocation_endpoint_auth_methods_supported: ["private_key_jwt", "none"] (none for canopy-cli), revocation_endpoint_auth_signing_alg_values_supported: ["ES256"] (RFC 8414 §2), response_types_supported: [], dpop_signing_alg_values_supported: ["ES256"] (RFC 9449 §5.1), and, while the device flow is served (an upstream profile and the verification page configured), device_authorization_endpoint ({issuer}/device_authorization, RFC 8628 §4). The endpoint URLs are built by path segment from CANOPY_SECURITYIDENTITY_ISSUER; in-cluster clients use the same paths under CANOPY_SECURITYIDENTITY_INTERNAL_URL.
Response (503): {"error": "temporarily_unavailable"} while the issuer settings are unset.
canopy-identity security administration (ADR-049 §12, Amendment 8, #2731–#2735)
The security-admin routes, under /identity/admin/ beside the token routes: outside /v1, the identity receiver and the OpenAPI document, each bearer checked by the routes' own guard (identity/admin/guard.rs). A caller is a security administrator presenting a canopy-identity delegation token. JSON comes in (at most 4 KiB) and RFC 9457 problem details go out, each refusal with its code. The routes share a per-IP limiter of 60 requests a minute and carry Cache-Control: no-store. A request has 5 s: the bearer and its session are checked by 2 s, the database answers by the end, and an overrun is 503. With the issuer or the admin login (CANOPY_SECURITY__IDENTITY_ADMIN_DATABASE_URL) unconfigured, every route answers 503 admin_unconfigured. Reads and writes go through the admin login’s pool. The path, the body limit, the request bodies, the answers and the input rules are canopy_auth::identity_admin's, shared with the routes' clients (ADR-049 Amendment 20; Shared crates). Source: services/canopy-security/src/identity/admin.rs and admin/.
Access, checked in this order:
-
The bearer,
Authorization: Bearer <token>: a canopy-identity delegation token for canopy-security (aud=urn:canopy:service:canopy-security), validated in process as every receiver validates one (IdentityTokenValidator, the last hop included), against the keys the JWKS serves. No bearer is 401token_missingwith a bareWWW-Authenticate: Bearer(RFC 6750 §3.1); a refused one 401token_rejectedwithBearer error="invalid_token"; keys unavailable, or unanswered by 2 s, 503keys_unavailable. -
Its session and clients: the session the token’s
sidnames is re-read and must be live, unrevoked, fresh, its subject the token’ssuband unsuspended, opened by the chain’s opener: else 401session_endedorsession_refused(invalid_token); a store that does not answer 503session_store_unavailable. Every client in the token’sactchain must be registered and enabled (a native client is refused), and not disabled at runtime (the token endpoint’s client status): else 401client_disabled; a client status that does not answer is 503client_status_unavailable. An administrator’s revocation or suspension therefore ends their administration at once, not after the token’s 300 s, and disabling the client their bearer came through ends it within 5 s. -
The role: the token’s roles must include
security_admin(the IdP must emit that exact name;admindoes not imply it): else 403insufficient_scope. -
Step-up: the token’s
auth_timemust be at most 600 s old (canopy_auth::SECURITY_ADMIN_MAX_AGE_SECONDS): else 401insufficient_user_authentication, withWWW-Authenticate: Bearer error="insufficient_user_authentication", error_description="A sign-in within the last 600 seconds is required", max_age=600(RFC 9470).
Each 401 and 403 is logged by its code and, once the token verifies, the canopy subject; never the token. An unavailable key set or store is logged by its own warning.
GET /identity/admin/subjects?upstream_iss=&upstream_sub=
The subject an exact upstream pair is effectively linked to: its latest re-link’s, else the subject it was minted for. upstream_iss must be visible ASCII, at most 2048 bytes, and upstream_sub 1 to 255 bytes of printable ASCII, else 400 upstream_pair_invalid, never echoing the input.
Response (200): {"subject_id": "<uuid>"}; 404 subject_not_found for an unlinked pair.
GET /identity/admin/subjects/{subject_id}
A subject’s effective links (each pair whose latest re-link, else whose link, names it), suspension and sessions, read in one snapshot. subject_id must be a canonical lowercase hyphenated UUID, else 400 subject_id_invalid.
Response (200): {"subject_id", "links": [{"upstream_iss", "upstream_sub"}], "suspended": bool, "sessions": [{"session_id", "opener", "auth_time", "ends_at", "fresh_until", "revoked": bool}]}. The sessions are the subject’s not yet purged, the most recent 100 first; fresh_until is the latest validation’s. 404 subject_not_found for an unknown subject. Each answered read is logged with the administrator’s and the subject’s canopy ids.
The writes
Each write’s body is {"reason": "<text>"} and nothing else: anything else is 400 body_invalid, and a reason that is empty, longer than 200 bytes or holds a control character (U+0000 to U+001F, U+007F to U+009F) is 400 reason_invalid. A path id must be a canonical lowercase hyphenated UUID, else 400 subject_id_invalid or session_id_invalid. No refusal echoes its input. A body over 4 KiB is 413.
Each write is one admin function in one READ COMMITTED transaction, which makes the change and records its identity_admin_actions row together: the action, the target, the reason, whether the state changed, and the bearer behind it (its subject, session, jti, the kid that signed it, and the client it came through). A write refused with a 4xx records nothing; after a 503 its outcome is unknown, and a retry answers changed: false if it committed.
Response (201): {"action_id": "<uuid>", "changed": bool}. changed is false for a write that left the state as it was, which is still recorded. Each write is logged with the administrator’s canopy id, the action, the target’s id and the action id.
POST /identity/admin/subjects (Amendment 11, #2766)
Creates a canopy subject with the given UUID: the seed link (ADR-049 §8), with the re-link below, and how a deployment adopts subject ids its data already holds. The body is {"subject_id", "reason"} and nothing else (else 400 body_invalid): subject_id a canonical lowercase hyphenated UUID of any version but the nil UUID (else 400 subject_id_invalid) and the reason. Neither is echoed. A subject that already exists is left as it is: changed false, still recorded. A created subject has no link, so nothing opens a session as it until POST /identity/admin/links links an upstream pair to it; the pair’s next open then resolves to it.
POST /identity/admin/subjects/{subject_id}/suspend, /lift (#2732)
Suspends a subject, or lifts its suspension, through the suspension writers, the administrator’s subject id as the event’s actor. A suspended subject’s delegation stops at once: every mint and every admin request re-reads suspension. Suspending an unsuspended subject, or lifting a suspended one, changes it; the repeat does not and writes no event. 404 subject_not_found for an unknown subject.
POST /identity/admin/links (#2734)
Links an upstream pair to a canopy subject, or re-links it from the subject it is linked to: the repair for an upstream issuer renamed, whose people sign in as new subjects. The body is {"upstream_iss", "upstream_sub", "subject_id", "reason"} and nothing else (else 400 body_invalid): the pair in the shapes the link table admits (upstream_iss visible ASCII, at most 2048 bytes; upstream_sub 1 to 255 bytes of printable ASCII; else 400 upstream_pair_invalid), subject_id a canonical lowercase hyphenated UUID (else 400 subject_id_invalid) and the reason. None of them is echoed.
Under the pair’s lock, an open of the pair in flight finishes first and one arriving waits:
-
a pair already linked to the subject:
changedfalse; -
an unlinked pair: linked to the subject, so its first sign-in opens as that subject (pre-linking a new issuer’s pair before anyone signs in under it);
-
a pair linked to another subject: re-linked, and its live sessions revoked with the reason
relinked, so its next sign-in opens as the subject. The subject it left keeps its other links and its history.
A subject holds at most one link per upstream issuer: a subject already linked under the pair’s issuer to another upstream subject is 409 link_conflict; re-link that pair away first. An unknown subject is 404 subject_not_found; no subject is created.
GET /identity/admin/keys (#2735)
The signing keys whose publish window has not ended by the database clock, revoked or not, newest first, at most 128 (the registry publishes at most 64 at once, and a revoked key frees its slot).
Response (200): {"keys": [{"kid", "created_at", "sign_from", "sign_until", "publish_until", "revoked_at"}]}, revoked_at null for an unrevoked key.
POST /identity/admin/keys/{kid}/revoke (#2735)
Revokes a signing key through identity_revoke_key, the administrator’s subject id as its actor and the admin login as revoked_by. kid must be an RFC 7638 thumbprint in the registry’s shape (43 characters of unpadded base64url), else 400 kid_invalid; an unknown kid is 404 key_not_found. Revoking a revoked key does not change it.
The JWKS drops the key within its memo’s 5 s, and each receiver refuses tokens under it once its keys refresh, this route’s own guard included: an administrator whose bearer the key signed is refused token_rejected from then on. The replica holding the key notices the revocation within 5 s and drops the key; it then signs nothing until its replacement’s 60 s publish lead has passed (#2738; security operations).
GET /identity/admin/clients (#2733)
Every compiled client, in compiled order, the confidential clients then the native one, with its kind, its registry entry and its runtime state, read from the admin pool (not the token endpoint’s memo, so a write shows at once).
Response (200): {"clients": [{"client", "kind", "registered": bool, "enabled": bool, "runtime_disabled": bool}]}. kind is confidential (authenticates by private_key_jwt under its registry entry) or native (canopy-cli, a public client bound by DPoP; ADR-049 Amendment 9, #2745). A confidential client’s registered and enabled are the registry’s (identity-clients.yaml); a client the registry does not enable is refused whatever runtime_disabled says, and enabling it at runtime does not override that. canopy-cli needs no registry entry, so it lists registered: false, enabled: true, and runtime disablement is its one switch.
POST /identity/admin/clients/{client}/disable, /enable (#2733)
Disables a client at runtime, or lifts its disablement, by the client’s next identity_client_disablements event, under the client’s advisory lock. client must be a compiled client’s exact id, confidential (canopy-web, canopy-snap, …) or native (canopy-cli, #2745), else 404 client_not_found. Disabling an enabled client, or enabling a disabled one, changes it; the repeat does not and writes no event.
A disablement holds on every replica from 5 s after it commits: each client authentication, at POST /identity/token and POST /identity/revoke, is then invalid_client (client_disabled), and each admin bearer through the client 401 client_disabled. Tokens already minted stay valid to their exp. canopy-cli’s disablement is held by the same client status: device authorization, the native grants and its revocation refuse a disabled canopy-cli (client_disabled), and code entry and device approval its user codes (device_client_disabled). Disabling canopy-web, the client every admin bearer comes through, therefore ends every administrator’s access within 5 s, the disabling one’s included: re-enabling it is then the migration identity’s SQL path (security operations).
POST /identity/admin/sessions/{session_id}/revoke (#2732)
Revokes a session with the reason admin, its revocation’s client the client the administrator came through. The session mints no further delegation and backs no further admin request. Revoking a revoked session does not change it. 404 session_not_found for an unknown session.
An administrator may act on themself: the write is answered 201, and the next request with the same bearer is refused 401 session_refused.
GET /identity/admin/actions (#2737)
The record of security administration, identity_admin_actions, one keyset page at a time, the newest first by recorded_at, then action_id. Every query parameter is optional and narrows the page; any other parameter is ignored:
-
action: one action’s name (suspend,lift,revoke_session,disable_client,enable_client,revoke_key,linkorcreate_subject;canopy_auth::AdminAction), else 400action_invalid; -
target: a canonical lowercase hyphenated UUID, matched against the target subject and the target session; a compiled client’s exact id; or a kid in the registry’s shape. Anything else is 400target_invalid; -
actor: the acting administrator’s subject, a canonical UUID, else 400actor_invalid; -
fromanduntil: RFC 3339 instants, a row recorded at or afterfromand beforeuntil. A malformed instant, or afromnot beforeuntil, is 400time_range_invalid; -
limit: 1 to 100 rows (canopy_auth::MAX_ACTIONS_PAGE), 50 when absent (DEFAULT_ACTIONS_PAGE), else 400limit_invalid; -
before_recorded_atandbefore_action_id: the cursor a previous page answered, both or neither, else 400cursor_invalid.
No refusal echoes its input. The server reads one row past the page to know whether another follows. Source: identity/admin/actions.rs.
Response (200): {"actions": […], "next": {"before_recorded_at", "before_action_id"} | null} (canopy_auth::ActionList). Each action carries every column of its row: action_id, recorded_at, action, the target columns (target_subject, target_session, target_client, target_kid, target_upstream_iss, target_upstream_sub, null where the action names none), the actor columns (actor_subject, actor_session, actor_token_jti, actor_token_kid, actor_client), reason and changed. next is null on the last page; otherwise it is the page’s last row, and sending its two fields back reads the next page. Each answered read is logged with the administrator’s canopy id.
Worker Directory (#597, ADR-046)
The JIT-populated (issuer, subject) directory behind every worker-portal
audit-actor name. Rows come ONLY from validated-login observations the BFF
reports (never IdP admin APIs — ADR-019); a worker who never logged in has
no row (the ADR-046 accepted limitation).
subject is an OidcSubject (#1008): 1–255 bytes of ASCII with no control
character, compared byte for byte and never trimmed or case-folded, so
" alice " and "alice" are two workers.
POST /v1/security/workers/observed
canopy-web’s sign-in observation, fired fire-and-forget from its sign-in
callback once the worker’s session is created (services/canopy-web/src/auth/routes.rs):
canopy-identity’s issuer, the worker’s canopy subject, the projected username
as display_name, the resolved role, and no email. Upserts on (issuer, subject):
display_name/email/role refresh to the observation, last_seen_at
advances, first_seen_at is write-once.
- Access
-
system (inline
Admission::system()): canopy-web’s system token, sent byWorkerObservedSink(services/canopy-web/src/worker_directory.rs); a user is 403system_caller_required
Request: WorkerObservedRequest
{
"issuer": "https://canopy.example.gov/identity",
"subject": "0f8a…",
"display_name": "jane.caseworker",
"email": "jane@agency.gov",
"role": "caseworker"
}
Response (204): no body.
Response (403): the admission’s refusal.
Response (422): blank issuer or display_name, or a subject that is
not a valid OIDC subject.
email is stored for operator use and never leaves the service
unmasked; no log line on this path carries it (ADR-046).
GET /v1/security/workers
Observed workers, last_seen_at DESC (active workers first — the
consumer-cache overflow rule), limit clamped to 200, offset paging,
optional role exact-match filter. Entries carry NO email field.
Consumers: the BFF names cache (#597) and the #702/#729 team enumeration.
- Access
-
system;
admin(SERVICE_OR_ADMIN). canopy-web reads it under its system token to fill its names cache (ServiceClients::worker_names,services/canopy-web/src/clients.rs)
Response (200): Vec<WorkerDirectoryEntry>.
GET /v1/security/workers/lookup
Query-borne key — ?issuer=&subject=, both required (an OIDC sub is an
opaque issuer-scoped string, #1008, and not path-segment-safe).
- Access
-
system;
admin(SERVICE_OR_ADMIN)
Response (200): WorkerLookupResponse — display_name, role,
email_masked (j@agency.gov), last_seen_at.
Response (400): a missing issuer or subject, or a subject that is
not a valid OIDC subject (the query fails to deserialize).
Response (404): no observation for that exact key.
Response* (422): blank issuer.
Admin replay
The shared canopy-api operator route (crates/canopy-api/src/admin.rs): main.rs merges canopy_api::AdminRoutes into the /v1 router, behind the receiver, and the handler admits its caller (#437, #1571). Replay is per service (ADR-001) — there is no cross-service replay endpoint.
POST /v1/admin/events/replay
Re-offer one or more of this service’s unprocessed event_inbox rows to its own handlers, in process (nothing is published); every requested id is classified in the response.
- Access
-
admin(canopy_api::admin::ADMIN_HUMAN,Admission::user_roles(&["admin"])): a system caller is 403service_class_on_user_only
Request: ReplayRequest — { "event_ids": ["uuid", …] }, the envelope ids to look up in this service’s event_inbox.
Response (200): ReplayReport — each requested id in exactly one of replayed, already_processed, missing, failed, unparked (a parked outbox row reset for the drainer), outbox_pending.
Response (403): a system caller (service_class_on_user_only), the portal (portal_on_non_portal_route), or a user without admin (required_role_missing).
Error Codes
| Code | Meaning |
|---|---|
400 |
|
401 |
No bearer ( |
403 |
The admission’s |
404 |
Event or alert not found; unknown/foreign verify-job id ( |
409 |
|
429 |
|
503 |
|
Background Processing
canopy-security runs these background tasks:
-
Event subscriber — wildcard RabbitMQ consumer (
canopy-security.audit) that persists every event toaudit_eventswith SHA-256 hash chain linking. It is batched (#2469,Subscriber::subscribe_raw_batched): after one delivery arrives it takes every further delivery the broker has already pushed, up toAUDIT_BATCH_MAX(32), without waiting — the consumer’s prefetch is raised to at least twice the cap (64), so under a backlog the next full batch is buffered while one commits — so an idle queue still chains a lone event at once. One transaction then dedupes the batch againstevent_inbox, takes the chain lock once, reads the predecessor once, links the rows in delivery order and commits once; the deliveries are acked only after that commit. The inbox stamps and the chain rows commit together, so an event is chained exactly once across a crash (a redelivery after the commit is already processed). A batch that fails at any step — a poison delivery, a database error — rolls back whole and every delivery replays alone on the per-delivery path, which keeps the retry count, the DLQ after 5 attempts and parking unchanged. The cap bounds how long one batch holds the chain lock the synchronousPOST /v1/security/audit/ingestalso waits on. -
Breach detection — periodic scan (60-second cycle) checking for privilege escalation patterns, abnormal access volumes, and FTI access anomalies. Generates
breach_alertrecords when thresholds are exceeded. -
chain-v2 verifiers (#1205 audit; #1206 the FTI families — all dormant: chain-v2 is withdrawn (ADR-041) and #1304 retires them; each runs only when
CANOPY_SECURITY__CHAIN_V2_VERIFY_ENABLED=trueAND its family’s verify-pool URL is set) — one task per configured family (audit, fti/canopy-tanf, fti/canopy-medicaid), each ordered by its FAMILY lease: halt gate → manual verify jobs first → manifest check + structural census → per-shard tail + scrub loops under a global pass budget. Verify pools parse at boot and connect lazily; one program DB outage degrades that family only. Integrity findings latch incidents (the family halts until the incident-resolution runbook clears them); coverage feedsGET /v1/security/chain/status. Design: the archived chain-v2 verifiers plan. -
audit-archive runner (#1208) — always spawned (a dormant scheduler still services manual admin runs), servicing
audit_archive_runsrows in per-chunk committed transactions; the scheduler arm is dormant unlessCANOPY_SECURITY__ARCHIVE_SCHEDULER_ENABLED=true. Mechanics and operator procedures: Security Operations › Archive Management.