Skip to content
Secrets StoreMarkdown

Rotate the secrets key

Add a new version of the realm's secrets key, and move the realm's own secrets onto it as they are written.

Available, with limitsAPI

Your key policy may ask for keys to be replaced on a schedule. Rotating the realm’s secrets key, which seals the realm’s own vault, adds a new version: everything written from then on is sealed under it, and everything written before still opens. No one notices.

Before you start: you are a realm administrator holding RealmOwner in this realm or a realm above it, signed in with your session in $CVYUH_SESSION (Call the API shows how). Users’ and groups’ vaults are under their own keys, which this doesn’t touch.

  1. Rotate the key:

    Terminal window
    curl -X PUT https://foobar.cvyuh.com/api/v0/am/keys/v1/secrets/encryption \
    -H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
    -H "Content-Type: application/json" \
    -d '{}'

    The realm answers 200 with the new version. Note it, with the time: a rotation isn’t on the realm’s audit trail yet.

  2. Each secret in the realm’s vault moves onto the new version the next time it is written, every version it holds sealed again. To move one now, write it again, here infra/db-root:

    Terminal window
    curl https://foobar.cvyuh.com/api/v0/vault/managed/v1/realm/data/infra/db-root \
    -H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
    -H "Content-Type: application/json" \
    -d '{ "data": { "user": "root", "password": "<password>" } }'

Read a secret written before the rotation: it still opens. No answer shows which key version a secret is under yet, so to be sure every secret has moved, write each one again: list them with a GET on https://foobar.cvyuh.com/api/v0/vault/managed/v1/realm/metadata?list=true.