Secret Rotation Runbook
This runbook covers rotating secrets for a Factory app Worker without downtime.Principles
- Rotate one secret at a time.
- Deploy the new secret before revoking the old one (allows overlap).
- Wrangler secrets are encrypted at rest; rotation is atomic per-secret.
Wrangler secret commands
Rotation procedures by secret
JWT_SECRET
JWTs already issued will be invalidated immediately. Schedule during low-traffic.
DATABASE_URL / HYPERDRIVE_*
Neon connection string rotation involves the Neon console.
STRIPE_SECRET_KEY
STRIPE_WEBHOOK_SECRET
ANTHROPIC_API_KEY / GROK_API_KEY / GROQ_API_KEY
SENTRY_DSN
Sentry DSNs are not sensitive (theyβre public endpoints). Rotation is only needed if the Sentry project is being deprecated.
GitHub Actions secrets
GitHub Actions secrets (used during CI/CD) are separate from Worker runtime secrets.NPM_TOKEN (deprecated after Trusted Publishers migration)
Factory package publishing uses npm Trusted Publishers (GitHub Actions OIDC), so NPM_TOKEN is no longer required for publish workflows.
Before revoking the legacy npm token, validate OIDC publish works:
- Trigger publish workflow once and confirm logs show npm publishing via GitHub Actions OIDC trusted publisher.
- Expected log indicators include
via GitHub Actions OIDC trusted publisherand a provenance line (npm notice Provenance statement). - Confirm the published package version has GitHub provenance in npmjs.com package details.
- npmjs.com β Access Tokens β revoke the old automation token.
- Remove
NPM_TOKENfrom GitHub Actions secrets in this repo (and app repos using OIDC publish).
Post-rotation verification checklist
- Worker
/healthreturns 200 - Auth endpoints issue and verify tokens correctly
- DB-backed endpoints return data
- Stripe webhook test event returns 200
- No new Sentry errors in the 15 minutes following rotation