Secret Management & Rotation
For an operator rotating a credential or adding a teammate to the secrets file. The storage model, the cargo xtask secrets subcommands, the YAML-to-environment mapping and every secret’s variable name are owned by Configuration Reference › Secrets; this page is the procedure.
Where secrets live
-
At rest: SOPS-encrypted YAML with age recipients (ADR-017) —
secrets/dev.yamlfor the devstack (fake values), a deployment-owned encrypted file for production..sops.yamllists the recipients; the private key is~/.config/sops/age/keys.txt(CI: the masked variableCANOPY_CI_AGE_KEY). -
In a process: environment variables, injected by
cargo xtask dev start|reload|restart|refreshon the devstack and by your deployment tooling in production. Services read them throughcanopy_secrets::EnvSecretProvider(crates/canopy-secrets/src/lib.rs), whichcanopy-api'sbootstrap_withuses forDATABASE_URL,MIGRATION_DATABASE_URLandRABBITMQ_URL(resolve_secrets) and for the service’s canopy-identity client key,IDENTITY_CLIENT_PRIVATE_KEY(crates/canopy-api/src/bootstrap.rs); signing keys are read the same way in each service’smain.rs. -
Never on the host:
ageandsopsrun inside thecanopy-devtoolscontainer (xtask/src/devtools.rs).
An environment variable is process-lifetime, so every rotation below ends in a restart of the consuming services.
Audit log shape
Every successful secret read emits one INFO event — the value is never logged:
{
"timestamp": "2026-09-23T12:00:00.000000Z",
"level": "INFO",
"message": "secret accessed",
"service": "canopy-snap",
"key": "CANOPY_SNAP__DATABASE_URL",
"source": "env",
"target": "canopy.secrets"
}
The variable’s name rides in key, not in a field called secret: every service’s logs pass through the ADR-041 redaction policy, and a field named secret is exactly what a policy redacts — canopy’s default secret rule among them (Rulesets › Logging redaction policy) — which would blank the one thing this audit line exists to record. A jurisdiction policy that adds a rule matching key does the same; keep key out of a pack’s [[logging.sensitive_fields]].
To see it on the devstack:
cargo xtask dev logs canopy-snap --tail 200 --no-follow | grep canopy.secrets
In production these lines flow with the rest of the structured logs (Deployment Guide › Observability) and are the evidence for IRS Pub 1075 §9.4.1.4 secret-access auditing.
Rotate a secret (devstack)
Preconditions: you are a recipient in .sops.yaml (otherwise an existing recipient runs cargo xtask secrets add-recipient <your age1…> first).
-
Change the value:
cargo xtask secrets edit(a signing key: paste the output ofcargo xtask secrets generate-signing-keyunder the service’ssigning_key:). -
Restart with the new environment — data kept:
cargo xtask dev reload. Neverdocker compose restart <service>:restartkeeps the existing container and its environment, so the rotated value is never applied, and a partial restart leaves peers on different values (Stale JWKS recovery). -
Verify:
cargo xtask dev logs <service> --tail 200 --no-follow | grep canopy.secretsshows the key being read, and/readyzanswers 200 (health).
Rollback: cargo xtask secrets edit back to the previous value, cargo xtask dev reload again. Git keeps the previous ciphertext.
Rotate a secret (production)
-
Rotate the credential at its source first (PostgreSQL
ALTER ROLE … PASSWORD, RabbitMQrabbitmqctl change_password, canopy-web’s client secret at the upstream IdP) with the old value still valid where the system allows two. -
Re-encrypt the new value into the deployment’s SOPS file with the same
cargo xtask secrets editflow against that file, or your platform’s equivalent. -
Redeploy the consuming services one at a time with the rolling procedure in Rolling deploy & rollback; each restart re-reads the environment.
-
Verify the
canopy.secretslines and/readyzon every restarted service, then revoke the old credential at its source.
CANOPY_<SVC>__DATABASE_URL rotation points at a different database, snapshot the old one first (cargo xtask migrate snapshot on a devstack, a base backup in production — Backup & Restore).
Recipients
-
Add: the new person runs
cargo xtask secrets initand sends the printed public key; an existing recipient runscargo xtask secrets add-recipient <age1…>and commits.sops.yamland the re-encryptedsecrets/dev.yaml. -
Remove: an existing recipient runs
cargo xtask secrets remove-recipient <age1…>— it drops the key from.sops.yaml(inline or foldedage:form), refuses to remove the last remaining recipient, and runssops updatekeys --yes secrets/dev.yamlso the re-encrypted data key no longer includes it (a key that is not listed is a no-op; a failedupdatekeysrestores.sops.yamlso nothing is half-applied); commit.sops.yamlandsecrets/dev.yamltogether. Removing a key protects only values encrypted afterwards — git history keeps every earlier ciphertext the removed key could open. Treat a departure as a rotation of every value in the file, using the procedures above; the recipient edit is hygiene, not revocation, and the command prints that reminder.
Which procedure for which secret
| Secret | Variable | Procedure |
|---|---|---|
Database password |
|
This page; annually and on suspected compromise. |
Broker password |
|
This page; annually and on suspected compromise. |
canopy-identity’s issuer and security-admin logins |
|
This page; on a suspected compromise, Security Operations › canopy-identity key registry (Compromise response) first. |
canopy-identity client keys |
|
Security Operations › canopy-identity client keys (register the incoming key beside the current one, deliver it, retire the old). |
canopy-web’s upstream client secret |
|
This page, after rotating the secret at the upstream IdP (IdP Integration › Registering canopy’s clients). |
canopy-identity signing keys |
none — each canopy-security replica holds its own in memory |
They rotate on their own (Security Operations › canopy-identity signing keys); if receivers refuse tokens, Stale JWKS recovery. |
Determination signing keys (ECDSA P-256) |
|
Signing Key Rotation (zero-downtime protocol; verifiers read |
Applicant ownership-claim keypair |
|
Security Operations › Key Rotation Runbook (staged public key, then cut over). |
PII encryption key (AES-256-GCM) |
|
Security Operations › The KEK — a two-key window plus the |
.env files for development and a planned HashiCorp Vault provider; ADR-017 (Accepted 2026-05-02) replaced that direction with SOPS + age, and the page now follows it.