TOKEN_ENCRYPTION_KEY
directly, as before.
Choose where the key encryption key lives
local still gives every organization its own data key; what it does not give
is a key that lives outside the application’s environment. The process needs
encrypt and decrypt on the key (kms:Encrypt, kms:Decrypt;
cloudkms.cryptoKeyVersions.useToEncrypt and useToDecrypt; the Transit
encrypt and decrypt paths). Each wrapped key is bound to its organization
and version: AWS through the encryption context, Cloud KMS through additional
authenticated data, Vault inside the wrapped value. A wrapped key copied onto
another organization does not unwrap there.
The provider and key are read at start. A misconfigured provider stops the
process at start rather than at the first secret.
Move existing secrets onto data keys
Secrets written before this release are on the master key (v2:). They keep
opening. To move them, run the re-encryption sweep once the release is
deployed:
docker compose -f infra/docker/docker-compose.prod.yml --env-file infra/docker/.env run --rm.
The sweep is idempotent and takes rows one organization at a time under that
organization’s row-level security context. See
reencrypt.
Rotate a data key
An owner rotates their organization’s data key under Settings → Identity → Encryption keys, orPOST /api/v1/settings/encryption/rotate. New secrets
use the new version at once. Older versions stay readable; the next
reencrypt apply moves every row onto the new one.
Rotating TOKEN_ENCRYPTION_KEY with KMS_PROVIDER=local follows
Rotate the encryption key: data keys wrapped under
the old master key keep unwrapping while it is listed in
TOKEN_ENCRYPTION_KEYS_PREVIOUS.
Customer-managed keys (Enterprise)
WithKMS_CUSTOMER_PROVIDERS=aws (or gcp), an owner of an organization on
the Enterprise plan can name a key in their own cloud account under
Settings → Identity → Encryption keys, or
PUT /api/v1/settings/encryption/customer-key. The key must grant this
deployment’s identity encrypt and decrypt (a key policy or grant in AWS, an IAM
binding in Google Cloud).
TRUSTIVAN first proves the key works with a wrap and unwrap of a test value,
then rewraps every version of the organization’s data key under it. No secret
is re-encrypted, so the change takes seconds. From then on the organization’s
secrets depend on that key:
- Disabling or deleting the key makes the organization’s stored secrets unreadable within five minutes (the unwrapped-key cache). Scans that need a registry credential and deliveries that need a signing secret fail until it is re-enabled.
- Stopping use (
DELETE /api/v1/settings/encryption/customer-key) rewraps the data keys back under the deployment key. The customer key must still be enabled for that.
encryption_key.changed or encryption_key.rotated.
What this does not do
- No automatic rotation. A data key rotates when an owner asks; the sweep runs when an operator runs it.
- No hardware module of our own. Keys live in the KMS you choose.
- Person-level secrets are not on data keys. They stay under
TOKEN_ENCRYPTION_KEY. - Customer-managed keys from Vault are not offered. Vault is available as the deployment’s own key encryption key only.
Related
- Rotate the encryption key
- Credentials: what is encrypted and what is only hashed.
- Environment