Rotate AUTH_SECRET
AUTH_SECRET signs session cookies. Rotating it invalidates every signature, so every browser session is signed out at once.
1
Generate a new value
2
Replace it in the root .env
Or in
apps/api/.env for a local development instance.3
Recreate the API
4
Sign in again
Every user has to. There is no way to rotate the signing secret without that.
AUTH_SECRET, so scripts and the MCP server keep working across a rotation. Revoke an individual token instead when that token is what leaked. See Personal API tokens.
Rotate the database password
The role password and the root.env must change together, so generate the value once and apply it to both before recreating the services.
alter role statement is required. The new value reaches the database over standard input rather than as a command line argument, so it stays out of the process list.
If the API fails to start afterwards, the role and .env disagree. Re run the block.
Rotate an OpenAI key
The simplest of the three. ReplaceOPENAI_API_KEY in apps/api/.env, recreate the API, then revoke the old key at OpenAI.
Related
Back up PostgreSQL
Take one before every rotation.
Hosting behind TLS and a reverse proxy
The rest of the pre exposure checklist.