Secret rotation
Use this runbook when a secret leaks, when a person with access leaves, or when you rotate on a schedule.
Each service reads a secret at a fixed time. That time decides whether the rotation needs a restart. The table was checked against the code.
| Secret | Read by | When it is read | Rotation needs |
|---|---|---|---|
PUSHLEFT_DEV_TOKEN (development mode only) | API | startup | API restart |
| API tokens and console sessions (production) | API | per request, by hash | nothing; revocation applies to the next request |
Registry token signing key PUSHLEFT_REGISTRY_TOKEN_KEY_FILE and certificate | gateway | startup (registry::load) | gateway restart, plus the registry’s rootcertbundle |
Registry realm secret PUSHLEFT_REGISTRY_SCHEDULER_SECRET_FILE | gateway, scheduler | startup (registry::load, Retention::from_env) | gateway and scheduler restart |
Vault token file PUSHLEFT_VAULT_TOKEN_FILE | gateway, API, controller, scheduler (leftovers), AI proxy, mail, git backup (nodes and the mesh controller hold none) | startup (VaultClient::new); git backup at each run | restart of that one service |
| Cloudflare token | controller (env value), mesh (file) | startup | restart |
DATABASE_URL passwords | every service | startup (pool) | restart |
| Gateway/telemetry TLS keys, agent CA key | gateways | startup | restart (CA/key compromise) |
For the expiry date of each credential, see credential lifetimes.
Development token
Development mode is loopback-only. Never use it in production.
-
Write a new token in the checkout. The script creates the file with mode 0600 and does not print the old value.
rm .env.herdr && scripts/dev setup -
Restart
scripts/dev apiand each shell that exportedPUSHLEFT_TOKEN.
The token was in git history once. We rotated it and rewrote the history on 17 October 2026, before the repository had a remote. If .env.herdr shows up in a diff again, rotate it in every checkout before you push.
Production API tokens
-
List the tokens of the organization. Admins see all of them.
curl -fsS -H "Authorization: Bearer $ADMIN" https://api.pushleft.dev/v1/auth/tokens -
Revoke the leaked token.
curl -fsS -X DELETE -H "Authorization: Bearer $ADMIN" -H 'X-Pushleft-CSRF: 1' https://api.pushleft.dev/v1/auth/tokens/<id> -
Issue a replacement, if one is needed.
curl -fsS -H "Authorization: Bearer $ADMIN" -H 'Content-Type: application/json' -d '{"name":"ci","service":true,"role":"member"}' https://api.pushleft.dev/v1/auth/tokens
The API checks revocation on the next request. SSE streams close within about 750 ms. Each revocation writes a token_revoked row in auth_events.
If the owner token is lost, issue a new token for the same owner (onboarding and revocation):
DATABASE_URL=$OWNER_URL pushleft-api bootstrap-owner --email <owner>
Registry credential
There is no registry login (H1, registry tokens). The gateway signs tokens that are valid for 15 minutes and for one repository. Two secrets remain: the signing key and the realm secret.
Signing key
The key is in PUSHLEFT_REGISTRY_TOKEN_KEY_FILE, and its certificate is in PUSHLEFT_REGISTRY_TOKEN_CERT_FILE.
-
Generate a new P-256 key and certificate.
openssl req -x509 -newkey ec -pkeyopt ec_paramgen_curve:P-256 -nodes -days 3650 \ -subj '/CN=pushleft registry token' -keyout registry-token.key -out registry-token.crt -
Append the new certificate to the registry’s
rootcertbundle. Keep the old one. -
Restart the registry.
-
Write the new key and certificate to the gateway’s files. The owner is
pushleft, and the key mode is 0600. -
Restart the gateway.
systemctl restart pushleft-agent-gateway -
Wait 15 minutes (the token lifetime).
-
Remove the old certificate from the bundle and restart the registry.
On a key compromise, do not wait at step 6. Remove the old certificate at once. Tokens in flight then fail, and their callers retry.
Realm secret
The gateway and the scheduler both read PUSHLEFT_REGISTRY_SCHEDULER_SECRET_FILE.
-
Write the same new secret to both files, with mode 0600.
openssl rand -hex 32 -
Restart the gateway and the scheduler. Deletes that fail between the two restarts are retried by the next retention pass.
Check the registry rotation worked
- A test
pl upreacheslive. - The next retention pass records
image_release_status = 'deleted'for an eligible artifact (registry retention).
Vault/OpenBao token
Nodes hold no Vault token. Of the services that hand node secrets out, only the gateway (pushleft-agent-gateway.hcl) holds one. The mesh controller holds none since 2026-11-03. The other tokens are on the control-plane host, one per service, each with its policy from deploy/vault:
| Service | Token file | Policy |
|---|---|---|
pushleft-agent-gateway | /etc/pushleft/agent-gateway/vault-token | pushleft-agent-gateway |
pushleft-api | /etc/pushleft/api/vault-token | pushleft-api |
pushleft-controller | /etc/pushleft/controller/vault-token | pushleft-controller |
pushleft-scheduler (since 2026-11-05, deletes purged projects’ leftovers) | /etc/pushleft/vault-scheduler/token | pushleft-scheduler-leftovers |
pushleft-ai-proxy | /etc/pushleft/ai-proxy/vault-token | pushleft-ai-proxy |
pushleft-mail | /etc/pushleft/mail/vault-token | pushleft-mail |
pushleft-git-backup (hourly oneshot) | /etc/pushleft/git-backup/vault-token | pushleft-git-backup |
The tokens are periodic orphans (token create -orphan -period=72h -policy=<policy>). Each service renews its own token while it runs (Vault service tokens). The tokens do not expire, so you rotate them only when you choose to.
-
Issue a new periodic orphan token with the same policy.
bao token create -orphan -period=72h -policy=<policy> -field=token -
Write it atomically to the service’s token file on the host, with mode 0600 and the service’s owner.
-
Restart that service. For the gateway, agents retry their lease and heartbeat calls, and leases survive a short restart.
pushleft-git-backupreads its file at its next run and needs no restart.systemctl restart pushleft-agent-gateway -
Revoke the old token in Vault after the service has restarted. Wrapping tokens that the gateway issued stay valid until their 5-minute TTL.
-
On older nodes that still have
/etc/pushleft/credentials/vault-token, delete the file and revoke that token.pushleft-agent doctorwarns while the file exists.
Check the Vault rotation worked
- A
manage_databaseensure_instanceorbackupjob succeeds, and the gateway logs nosecret wrap failed. - The restarted service’s
/readyzanswers 200, and it logs novault_token_renewal_failed.
If Vault itself is lost or sealed, use Vault recovery.
Database passwords
-
Set the new password on the role.
ALTER ROLE pushleft_<service> PASSWORD '...'; -
Update
DATABASE_URLin/etc/pushleft/<service>.env. -
Restart that one service. Existing connections keep working until the restart.
Do not
- Do not put secret values into
jobs.payload,deployment_eventsor results. The gateway refuses secret-shaped result fields. Nothing else checks. - Do not loosen file modes to share a file between users. The binaries refuse key files that a group or other users can read.