Key rotation
When. On a schedule your security policy sets, when someone who held a key leaves, or at once when a key may have leaked. Each section below says what the key protects, how to rotate it without an outage, and what an emergency rotation costs.
| Secret | Overlap supported | Section |
|---|---|---|
| JWT signing keys | Yes: automatic rotation with overlap; fc-server signing-keys for early or emergency rotation |
JWT signing key |
| App key | Yes: a list of previous keys, a re-encryption command and lazy re-hashing | App key |
| Database credentials | Yes on AWS Secrets Manager; otherwise by restart | Database credentials |
| Identity-provider client secrets | Yes, at the provider | Identity-provider secrets |
| OAuth client secrets | Yes: a grace period, 24 hours by default | OAuth clients and service accounts |
| Service-account signing secrets | No | OAuth clients and service accounts |
| Push stream secret | No: clients subscribe again | Push and router |
The JWT signing key
Section titled “The JWT signing key”With FLOWCATALYST_APP_KEY set, FC_JWT_KEY_STORE defaults to database: the platform keeps its signing
keys in PostgreSQL (the jwt_signing_keys table) and rotates them itself. You do not roll keys through
configuration. Each token type is signed as follows:
| Algorithm | Signs | Published in the JWKS |
|---|---|---|
| RS256 (RSA) | Access tokens, field-worker tokens, client assertions to identity providers, and id_tokens unless the OAuth client picks another algorithm |
Yes |
| EdDSA (Ed25519) | id_tokens of OAuth clients that choose it; access tokens when FC_JWT_ACCESS_TOKEN_ALG=EdDSA |
Yes |
| ML-DSA-65 | id_tokens of OAuth clients that choose it |
Yes |
| HS256 | Session cookies | No: only the platform verifies them |
The keyring always holds a key of every algorithm. Each key goes through four states:
| State | Signs | Verifies and published | Moves on when |
|---|---|---|---|
PENDING |
No | Yes | It has been published for the lead time: 24 hours for RS256, EdDSA and ML-DSA-65, so relying parties pick it up from their cached JWKS; 5 minutes for HS256 |
ACTIVE |
Yes | Yes | Its successor becomes ACTIVE |
RETIRED |
No | Yes | The retire grace passes: the longest token lifetime plus an hour |
EXPIRED |
No | No | Never: the row stays and the private key is erased |
An ACTIVE key gets a PENDING successor after 90 days (HS256 after 30). Only processes that run the
platform API (FC_PLATFORM_ENABLED=true) rotate. Each step runs once a minute inside one transaction that
holds an advisory lock, so replicas never rotate at the same time. Every process, a separate push gateway
included, reloads the keyring every 30 seconds. Each change is written to the audit log under the entity type
JwtSigningKey (KeyGenerated, KeyImported, KeyActivated, KeyRetired, KeyExpired).
So the routine rotation needs nothing from you except that every process that signs or verifies has
FLOWCATALYST_APP_KEY: the private keys are sealed with it. Moving to a new app key re-seals them with every
other secret (see the app key).
See the keys. Run the subcommands with the same environment as the API tier (they connect to the database
the server would use and need FLOWCATALYST_APP_KEY):
fc-server signing-keys list # kid, algorithm, status, source and dates of every keyRotate early.
fc-server signing-keys rotate --alg RS256 # a successor, signing after the usual leadfc-server signing-keys rotate --alg RS256 --immediate # the successor signs now; the old key is RETIREDfc-server signing-keys expire <kid> # end a PENDING or RETIRED key now--alg is RS256, EdDSA, ML-DSA-65 or HS256. An immediately rotated key keeps verifying for the retire
grace, so nothing in flight breaks. expire stops a key verifying on every process within 30 seconds and
erases its private key.
Emergency: a key may have leaked. Run rotate --alg <alg> --immediate, then expire <old kid>. Every
token the old key signed stops verifying within 30 seconds: people whose session cookie it signed sign in
again, and applications fetch new tokens. After an immediate rotation, a relying party whose cached JWKS
predates the new key fails to verify new id_tokens until it fetches the JWKS again; most libraries refetch
on an unknown kid.
Emergency: an algorithm is broken (RSA factored, for instance). Run rotate --immediate and expire for
every RS256 kid. Then move access tokens to EdDSA with FC_JWT_ACCESS_TOKEN_ALG and every OAuth client to
EdDSA or ML-DSA-65. Client assertions to external identity providers stay RS256 (Microsoft Entra requires it),
and so do field-worker tokens.
First boot of the keyring, and an upgraded deployment
Section titled “First boot of the keyring, and an upgraded deployment”The first API process to start with the keyring adopts the RSA key from configuration
(FLOWCATALYST_JWT_PRIVATE_KEY, FC_JWT_SIGNING_KEY_PEM or FC_JWT_SIGNING_KEY_PATH) as the ACTIVE RS256
key, under the kid it always had, so outstanding tokens and cached JWKS stay valid. It generates the
EdDSA and HS256 keys and an ML-DSA-65 key (adopting a configured one if there is one). The adopted key is
rotated away 90 days later. After that the key in configuration is no longer used, and an expired key is never
adopted again: remove it from configuration once signing-keys list shows it EXPIRED.
FLOWCATALYST_JWT_PREVIOUS_PUBLIC_KEY is not used with the keyring.
FC_JWT_KEY_STORE=config: the manual procedure
Section titled “FC_JWT_KEY_STORE=config: the manual procedure”Set FC_JWT_KEY_STORE=config (or leave FLOWCATALYST_APP_KEY unset) and the platform signs with the keys in
configuration, never rotates them, and signs session cookies with RS256, as it did before the keyring. Then
rotation is by hand. FLOWCATALYST_JWT_PREVIOUS_PUBLIC_KEY adds one public key that is accepted when
validating and listed in the JWKS, but never used to sign. Use it twice, in three rolls:
openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -out new.pemopenssl pkey -in new.pem -pubout -out new.pub.pemopenssl pkey -in current.pem -pubout -out current.pub.pem- Publish the new key. Keep the current private key; set
FLOWCATALYST_JWT_PREVIOUS_PUBLIC_KEYtonew.pub.pem. Roll every process that issues or validates tokens (the API tier and a separate push gateway). Every process now accepts both keys, and applications and resource servers that cache the JWKS see the new key before anything is signed with it. Wait at least as long as they cache the JWKS. - Switch. Set the private key to
new.pemandFLOWCATALYST_JWT_PREVIOUS_PUBLIC_KEYtocurrent.pub.pem. Roll again. New tokens are signed with the new key; tokens signed with the old one still validate, on every process, throughout the roll. - Retire. After the longest-lived token signed with the old key has expired (the session
lifetime, 24 hours by default), remove
FLOWCATALYST_JWT_PREVIOUS_PUBLIC_KEYand roll once more.
Doing step 2 without step 1 also works, but during the roll the replicas still on the old key refuse tokens the new ones issue.
Emergency. If the private key leaked, skip the overlap: install the new key with no previous key and restart everything at once. Every session and token becomes invalid: people sign in again, applications fetch new client-credentials tokens, field workers sign in again.
The app key
Section titled “The app key”FLOWCATALYST_APP_KEY (base64, 32 bytes) encrypts secrets at rest, keys the hashes of verify-only secrets,
and is the root of two derived keys: the HMAC key that signs dispatch-job tokens, and the pepper of
field-worker PIN hashes. FLOWCATALYST_APP_KEY_PREVIOUS is a comma-separated list of retired keys
(older,oldest; a single value is a list of one). New writes always use the current key. Reads and
verification try the current key, then every previous one. A malformed entry, like a malformed current
key, stops every tier at boot.
| Protected by the app key | During and after a rotation |
|---|---|
| Encrypted columns (AES-256-GCM): secret platform-configuration values, service-account webhook token and signing secret, identity-provider and client-auth OIDC client secrets, TOTP secrets, function secret and database settings, legacy encrypted OAuth-client and developer secrets | Read through any previous key. fc-server reencrypt moves every stored value to the current key |
Verify-only secrets (hashed:v1:): OAuth client secrets, service-account client secrets, developer credentials |
Verify under the current key or any previous one. A secret that verifies only under a previous key is re-hashed under the current key on that request. They cannot be re-hashed in bulk, because the platform never holds the plaintext |
| Dispatch-job auth tokens | The scheduler signs with the current key. /api/dispatch/process and /api/dispatch/settled accept a token signed under the current key or any previous one. Nothing is stored: a job on the queue carries its token until delivery, or until stale recovery (15 minutes) puts it back to PENDING and it is signed again |
| Field-worker PIN pepper | New hashes use the current pepper and store its id in field_identities.pin_pepper_id. Verification picks the pepper by that id, or, for a hash stored before ids existed, tries the current pepper and then each previous one. The first successful sign-in after a rotation re-hashes the PIN under the current pepper |
With the signing keyring (FC_JWT_KEY_STORE=database) the private signing keys are sealed with the app key
too, each bound to its kid, and fc-server reencrypt moves them to the current key with the other
encrypted columns. With FC_JWT_KEY_STORE=config the signing key does not derive from the app key.
Not covered here, because they do not derive from the app key: FC_PUSH_STREAM_SECRET, database
credentials, and secrets held in a secret manager (aws-sm://, aws-ps://).
Generate the new key with openssl rand -base64 32. Store it apart from the database backups, and keep
the old key until the last step below is done.
1. Make every process accept the new key
Section titled “1. Make every process accept the new key”Every process that has FLOWCATALYST_APP_KEY in its environment needs the change: every fc-server
tier (API, scheduler, stream, outbox, push) and any one-off task.
During a rolling deploy, processes with the old key and processes with the new key run at the same time. A process still on the old key cannot read a value written with the new key, and an API tier on the old key rejects a dispatch token signed by a scheduler already on the new key. To avoid any errors, deploy twice:
FLOWCATALYST_APP_KEY=<old>,FLOWCATALYST_APP_KEY_PREVIOUS=<new>. Nothing is written with the new key yet, but every process can now read it.FLOWCATALYST_APP_KEY=<new>,FLOWCATALYST_APP_KEY_PREVIOUS=<old>.
If a few minutes of errors during the rollout are acceptable, step 2 alone is enough.
Watch fc_dispatch_job_auth_rejected_total while the deploy runs. It should stay at zero. If it climbs,
two tiers disagree about the key: a rejected token gets a 401, the router does not ACK it, and the job
comes back only through stale recovery, again and again.
2. Re-encrypt the stored values
Section titled “2. Re-encrypt the stored values”When every process runs with the new key as current, run this with the same environment as the API tier. It is safe while the platform is serving traffic:
fc-server reencrypt --dry-run # counts onlyfc-server reencrypt- It reads each encrypted column in primary-key order, in batches (
--batch-size, default 500). - It rewrites each value that is not yet on the current key in its own statement. The update is a
compare-and-set on the exact ciphertext it read, so it never overwrites a value written in the
meantime; those rows are counted as
CHANGED_MEANWHILE. - Values already on the current key are skipped, so if it stops, run it again.
- It connects to the database the server would use (
FC_DATABASE_URLorDATABASE_URL, orDB_SECRET_ARNwithDB_HOST) and does not run migrations.
Exit status: 0 done; 1 error (run it again to resume); 2 usage; 3 done, but some values could not
be opened with any configured key. The log lists those rows, never their values. They were already
unreadable before the rotation: fix or re-enter them.
HASHED counts verify-only secrets and EXTERNAL counts secret-manager references; neither is touched.
NOT_ENCRYPTED counts legacy plaintext in columns that encrypt lazily on the next write. A dry run after
the real run should show WOULD_REENCRYPT 0 for every target.
3. Let the lazy migrations catch up
Section titled “3. Let the lazy migrations catch up”-
PINs are re-hashed when each worker next signs in. Until then they keep working, as long as the old key stays in
FLOWCATALYST_APP_KEY_PREVIOUS. To see progress:SELECT pin_pepper_id, count(*) FROM field_identitiesWHERE pin_hash IS NOT NULL AND pin_scheme = 'PEPPER_V1' GROUP BY 1;PINs set after the rotation carry the current pepper’s id. A NULL id is a hash stored before pepper ids existed; it may be under either key.
-
Verify-only client secrets are re-hashed the next time each client authenticates. There is no way to tell which key an existing hash was made under, so a client that does not authenticate while the old key is still listed stops working when the old key is dropped, and its secret then has to be rotated. Before dropping the key, list the secrets not re-hashed since the rotation went out (a re-hash rewrites the row, so its update time moves), with
$1the time the new key was deployed:SELECT 'oauth client' AS kind, id, client_id AS name, updated_at AS last_changeFROM oauth_clientsWHERE client_secret_ref LIKE 'hashed:v1:%' AND updated_at < $1UNION ALLSELECT 'developer credential', id, name, dev_client_secret_updated_atFROM iam_principalsWHERE dev_client_secret_ref LIKE 'hashed:v1:%' AND dev_client_secret_updated_at < $1;Each row is a client that has not authenticated since the rotation: ask its owner to use it, or plan to reissue its secret once the key is dropped. The list can miss a client whose row changed for another reason after the rotation (an edit in the console), so treat it as the likely casualties, not a proof that no other will fail. A client’s previous secret during a secret rotation (
previous_secret_ref) follows the same rule and expires with its grace period.
4. Drop the old key
Section titled “4. Drop the old key”Remove the old key from FLOWCATALYST_APP_KEY_PREVIOUS and deploy, once all of these hold:
fc-server reencrypt --dry-runreportsWOULD_REENCRYPT0 andUNREADABLE0.fc_dispatch_job_auth_previous_key_totalhas stayed flat for longer than a job can sit on the queue: at least the 15-minute stale-recovery window, plus any subscriptiondelaySeconds. It counts job tokens that verified only under a previous key.- You accept what happens to anything not yet migrated:
- A worker who has not signed in since the rotation cannot sign in. Sign-in is refused with 403
PIN_RESET_REQUIRED(“this PIN was set under a retired key and must be reset by a supervisor”), and it does not count as a wrong PIN, so there is no lockout. Changing a PIN and acting as a worker give the same answer. A supervisor resetting the PIN fixes it. See Field worker protocol. - A client whose verify-only secret was not used since the rotation needs a new secret.
- A worker who has not signed in since the rotation cannot sign in. Sign-in is refused with 403
Keep a copy of the old key until you are sure: putting it back in FLOWCATALYST_APP_KEY_PREVIOUS makes
everything above readable again.
Emergency. If the app key leaked, assume every secret in the database is exposed. Rotate the secrets
themselves at their sources (identity-provider client secrets, database passwords held in configuration,
API keys in function and ingestion secrets) and re-enter them, in addition to the steps above.
cmd/decrypt-check in the platform repository tests whether a given key opens a given ciphertext.
Database credentials
Section titled “Database credentials”On AWS with Secrets Manager (DB_SECRET_ARN), the platform re-reads the secret every
DB_SECRET_REFRESH_INTERVAL_MS (5 minutes) and opens new connections with the current credentials;
existing connections continue. Use RDS-managed rotation (the alternating-users strategy avoids any
gap). No restart is needed.
Everywhere else the credentials are read at start-up from FC_DATABASE_URL or DB_PASSWORD. Change
the password in PostgreSQL and the secret store, then roll every database-backed process promptly.
Existing connections keep working until the pool recycles them (at most an hour), but any new
connection opened before a process restarts fails. A process with only the router (SQS) or only the
function runner has no database connection.
Identity-provider client secrets
Section titled “Identity-provider client secrets”Each SSO identity provider’s client secret is stored encrypted on the identity provider in the console. Most providers allow two client secrets at once, which makes this overlap-free:
- Create a new client secret at the provider; keep the old one.
- Paste the new secret into the identity provider in the console and save. The next sign-in uses it; no restart is needed.
- Sign in through that provider to confirm.
- Delete the old secret at the provider.
If sign-ins fail afterwards with code exchange failed, see
IdP login failures.
Rotating an identity-provider certificate
Section titled “Rotating an identity-provider certificate”An OIDC identity provider can authenticate the platform with a certificate instead of a client secret
(oidcClientAuthMethod CERTIFICATE). The platform generates the RSA 3072 key pair and a self-signed
certificate, valid for 24 months, and keeps the private key encrypted with the app key. At most two
certificates exist per provider: ACTIVE, which signs, and NEXT. Rotate with overlap, in the /ui
console, on the identity provider’s page, before the active certificate expires (the page warns when it
expires within 60 days):
- Choose Generate next. The new certificate is
NEXT; the active one keeps signing. - Download the
NEXTcertificate (Download .cer) and upload it at the provider (in Microsoft Entra: App registrations, your app, Certificates & secrets, Certificates). The provider now trusts both. - Choose Make active. The next sign-in uses the new certificate, with no restart, and the old certificate is deleted.
Discard deletes an unwanted NEXT certificate. Promoting with no NEXT is refused with
NO_NEXT_CERTIFICATE. Deleting the identity provider deletes its certificates.
A provider set to FEDERATED has no certificate or secret to rotate: the platform signs the assertion with
its own RS256 signing key from the JWKS, so the keyring’s automatic rotation covers it. The provider side
trusts the platform’s issuer, not a key.
OAuth clients and service accounts
Section titled “OAuth clients and service accounts”- OAuth client secrets (
POST /api/oauth-clients/{id}/rotate-secret) keep the old secret valid for a grace period: 24 hours by default,graceSecondsto choose,0for an immediate cutover. Deploy the new secret to the client within the grace period; end the overlap early withPOST /api/oauth-clients/{id}/revoke-previous-secret. The router, function runners and ingestor runtimes authenticate this way, as do applications. - Service-account signing secrets (
POST /api/service-accounts/{id}/regenerate-signing-secret) sign webhook deliveries through the connections that use the account. There is no overlap: deliveries after the change carry signatures made with the new secret, so coordinate with the consumers that verify them.
Push and router credentials
Section titled “Push and router credentials”FC_PUSH_STREAM_SECRETsigns push stream tokens (valid for at most an hour). Changing it on every gateway replica at once invalidates every open stream token; clients getSTREAM_TOKEN_INVALIDand subscribe again. Roll the gateways quickly so replicas do not disagree.- Router Basic auth (
FC_ROUTER_AUTH_USER,FC_ROUTER_AUTH_PASS): change it and roll the router processes; update whatever scrapes or calls the router’s operator API.
Read next
Section titled “Read next”- Configuring a deployment.
- Security hardening checklist.
- Backup and disaster recovery: back keys up apart from the database.