Skip to main content

Rotate the JWT Signing Keys

OpenMetadata signs the JWT tokens it issues with one RSA key pair, set in jwtTokenConfiguration. These tokens include user sessions, personal access tokens, and bot tokens such as the one the ingestion-bot uses. Rotate the key pair when you replace the default keys shipped for testing, when the private key may have leaked, or when your security policy requires it. Rotation is a hard cut. You stop every server, start them all with the new key pair, regenerate the bot tokens, and redeploy the ingestion pipelines. Tokens signed by the old key stop working.
Plan for downtime. Every server is stopped during the restart. Between the restart and the bot token regeneration, every bot (ingestion, automation, and integrations) is rejected with 401 Unauthorized. Users must sign in again, and every personal access token stops working.

Before You Start

Check the following before you rotate the keys:
  • You have picked a time when bot downtime is acceptable.
  • You have shell access to a host, container, or pod that can run ./bootstrap/openmetadata-ops.sh. It needs the same configuration as the servers and network access to the server API. A server container or pod meets both conditions.
  • pipelineServiceClientConfiguration.metadataApiEndpoint (SERVER_HOST_API_URL) is set in that configuration. The deploy-pipelines command redeploys pipelines through this endpoint.
  • To regenerate the bot tokens with a command, you need OpenMetadata 2.0.10 or later. On earlier 2.0 releases, you regenerate them in the UI.

Step 1: Create a New Key Pair

OpenMetadata reads the private key as DER PKCS#8 and the public key as DER X.509. Use keys of 2048 bits or more:
Generate a new key ID:
The new key ID must differ from the current JWT_KEY_ID, so that services that cache the JWKS fetch the new key. The Enable JWT Tokens page asks you to keep the key ID unchanged across upgrades. A key rotation is the exception. Keep private_key.der secret. Make it readable only by the user that runs the OpenMetadata server.

Step 2: Restart Every Server with the New Keys

Stop every OpenMetadata server before you start any server with the new keys. Do not use a rolling restart. During a rolling restart, a restarted server can fetch the old public key from a server that has not restarted yet. This happens when authenticationConfiguration.publicKeyUrls (AUTHENTICATION_PUBLIC_KEYS) points to an OpenMetadata URL behind a load balancer. The server caches that key for up to 24 hours and keeps accepting old user sessions and personal access tokens. The default localhost JWKS URL avoids this problem. Set the following values in the configuration of every server and of the host that runs openmetadata-ops.sh. All of them must hold the same values. Follow the steps for your deployment:
  1. Stop every OpenMetadata server.
  2. Copy private_key.der and public_key.der to the OpenMetadata conf directory of each server, or to the paths set in RSA_PRIVATE_KEY_FILE_PATH and RSA_PUBLIC_KEY_FILE_PATH.
  3. Set JWT_KEY_ID, or jwtTokenConfiguration.keyId in conf/openmetadata.yaml, to the new key ID.
  4. Start every server.
After the servers start, check that each server lists only the new key ID:
Query each server directly. A request through the load balancer checks only one of them. If a rolling restart already happened with a shared JWKS URL, stop all servers and start them again to clear the cached old key. From this point:
  • Users get 401 Unauthorized on their old sessions and must sign in again.
  • Holders of personal access tokens must create new tokens.
  • Bots stay rejected until you complete step 3.

Step 3: Regenerate the Bot Tokens

Give every bot a new token signed by the new key. The method depends on your OpenMetadata version.
Run regenerate-bot-tokens from the OpenMetadata server directory, with the same configuration the servers use:
The command gives every bot that uses JWT authentication a new token, signed by the key in its configuration. Use --expiry to set the expiry of the new tokens: OneHour, One, Seven, Thirty, Sixty, Ninety, or Unlimited. The default is Unlimited.The command prints one row per bot with one of these outcomes:
  • SUCCESS: The bot has a new token.
  • SKIPPED: The bot has no bot user or doesn’t use JWT authentication.
  • FAILED: The token wasn’t replaced. The details column gives the reason.
The command exits with code 0 when no bot failed and 1 otherwise.
In OpenMetadata 2.0, the command doesn’t check that its key matches the key the servers use. If its configuration holds a different key, it stores tokens that every server rejects. Make sure the host that runs the command uses the same key files and key ID as the servers.The command also gives a new token to bots whose token was revoked. After it runs, go to Settings > Bots and revoke the token of each of those bots again.
A bot works again as soon as its new token is stored. You don’t need to restart the servers.

Step 4: Redeploy the Ingestion Pipelines

Deployed pipelines still carry the old ingestion-bot token. Redeploy them so that they use the new one:
Run it in the same place as the regenerate-bot-tokens command, for example with docker exec or kubectl exec. The command deploys every pipeline registered in OpenMetadata. For pipelines managed outside OpenMetadata, replace the bot token in their configuration and redeploy them through their own scheduler.

Step 5: Check the Result

Confirm the following:
  • /api/v1/system/config/jwks on each server lists only the new key ID.
  • Every bot has a new token. With the command, every bot shows as SUCCESS, or SKIPPED if it doesn’t use JWT authentication.
  • Ingestion pipelines run again, on schedule or when you trigger them manually.

Update Tokens Stored Outside OpenMetadata

The new keys invalidate copies of old tokens that other systems hold. Update the following:
  • Personal access tokens: Rotation doesn’t re-sign or delete personal access tokens. The old tokens can still appear as unexpired in the UI, but requests that use them return 401 Unauthorized. Ask their owners to revoke the old tokens, create new ones, and update their clients.
  • Copied bot tokens: Copy the new token from Settings > Bots to every system that holds the old one, such as CI jobs and external pipelines.
  • Airflow lineage backend: Replace jwt_token in the [lineage] section of airflow.cfg, or metadata_config.securityConfig.jwtToken in the JSON file set in OPENMETADATA_LINEAGE_CONFIG. Pipeline redeployment doesn’t update these values.
  • Airflow OpenMetadataHook: Replace the password of the Airflow connection that the hook uses, openmetadata_default by default. Pipeline redeployment doesn’t update this connection.
  • Services that verify OpenMetadata tokens through the JWKS: Make sure they reload the JWKS and accept the new key ID. Remove any cached or pinned copy of the old public key, so that they reject tokens signed by it.