Key Rotation

On this page

FusionAuth uses several kinds of secrets: API keys, signing keys, and client secrets. Rotating each secret regularly limits how long an attacker can use a leaked secret. A tested rotation process also lets you rotate on demand, such as after a suspected compromise or when an employee leaves.

The rotation steps stay the same for a scheduled rotation and a rotation after a compromise. After a compromise, rotate right away and shorten any grace period.

Choose the Rotation Guide#

Each kind of secret has a different audience and a different rotation process:

Secret Used by Grace period during rotation Guide
API key Scripts, servers, and admin tools that call the FusionAuth APIs Run the old and new keys side by side, and set expirationInstant on the old key API Key Rotation
Signing key FusionAuth, to sign JWTs, SAML responses, and webhook events. Your applications verify the signatures. Keep the old key as a verification key until the tokens the old key signed expire Signing Key Rotation
Client secret Confidential OAuth clients, during grants such as the authorization code grantAn OAuth 2.0 grant type in which a client exchanges an authorization code for tokens. and the client credentials grantAn OAuth 2.0 grant type in which a client uses its own credentials to obtain an access token for itself. None, because an Application or Entity has one client secret Client Secret Rotation

Distribute New Secrets#

Every rotation ends with each client using the new secret. Delete or replace an old secret only after every client has the new secret, because a client with the old secret then fails. The following approaches keep clients up to date:

  • Store secrets in a central secrets manager, such as AWS Secrets Manager or HashiCorp Vault, so you update each secret in one place.
  • Automate pushing new secrets to every client that needs the secret.
  • Allow a grace period between issuing the new secret and removing the old secret.