Skip to content

Encryption

Endpoints for a TOKEN_ENCRYPTION_KEY rotation. Rotating the encryption key describes the whole procedure.

GET /admin/encryption/rotation

Requires settings:manage, or the platform principal. Counts how many stored values each store holds that only TOKEN_ENCRYPTION_KEY_PREVIOUS opens, that are still plaintext, or that neither key opens. Every call reads the stored values again, so previous_key_can_go is never true while a value still needs the previous key.

curl
curl -s http://127.0.0.1:3000/admin/encryption/rotation \  -H "Authorization: Bearer $TOKEN"

Response: 200 OK. This one is from part way through a re-seal, with stores cut to three of its fourteen entries:

{
"key_configured": true,
"previous_key_configured": true,
"previous_key_can_go": false,
"remaining": 3,
"unsealed": 0,
"unreadable": 0,
"stores": [
{ "store": "oauth_client_keys", "previous": 1, "unsealed": 0, "unreadable": 0 },
{ "store": "attestation_key", "previous": 1, "unsealed": 0, "unreadable": 0 },
{ "store": "delegation_key", "previous": 1, "unsealed": 0, "unreadable": 0 }
],
"job": { "id": "ffd3922d-db8d-4fd9-a287-be128500c3be", "status": "running", "progress": null }
}
FieldTypeDescription
key_configuredbooleanWhether TOKEN_ENCRYPTION_KEY is set
previous_key_configuredbooleanWhether TOKEN_ENCRYPTION_KEY_PREVIOUS is set to a key other than TOKEN_ENCRYPTION_KEY
previous_key_can_gobooleanSafe to unset TOKEN_ENCRYPTION_KEY_PREVIOUS: it’s configured, and remaining is 0. Always false when it isn’t configured
remainingintegerValues only the previous key opens
unsealedintegerPlaintext values, written while the instance ran without a key. The next boot’s re-seal encrypts them
unreadableintegerValues neither key opens. They can’t be re-sealed
storesarrayprevious, unsealed and unreadable for each store. See below
jobobject or nullThe happyview.reseal job that is pending, running, pausing or paused, as id, status and progress. progress is null until the job has finished its pass. null when there’s no such job

The stores are dpop_keys, dpop_sessions, oauth_client_keys, external_account_tokens, service_identity, verification_methods, space_dids, attestation_key, delegation_key, script_variables, oauth_sessions, linked_repo_sessions, oauth_state and plugin_secrets.

When TOKEN_ENCRYPTION_KEY isn’t set, the response has no unsealed or unreadable:

{
"key_configured": false,
"previous_key_configured": false,
"previous_key_can_go": false,
"remaining": 0,
"stores": [],
"job": null
}
POST /admin/encryption/rotation

Requires settings:manage. If a happyview.reseal job is pending, running, pausing or paused, the response names that job and no new one is created; otherwise a new job is queued. Boot already queues one when anything needs re-sealing, so call this only when that job ended before finishing.

curl
curl -s -X POST http://127.0.0.1:3000/admin/encryption/rotation \  -H "Authorization: Bearer $TOKEN"

Response: 202 Accepted

{ "job_id": "ffd3922d-db8d-4fd9-a287-be128500c3be" }

With no TOKEN_ENCRYPTION_KEY there’s nothing to re-seal with, and the answer is 400. The platform principal can read the status but not start a job, so it gets 403.