You're viewing the docs for Config 0.x. The latest is 1.x (rc). Go to the 1.x (rc) docs
Secrets
Never stored in plain text — encrypted at rest with the app key, or resolved from a vault.
An entry is a secret when it was written as one (secret: true), or when its value is a vault://
reference. Secret values are never stored in plain text.
Encrypted at rest
Secret values are sealed by the Agora crypto kit, the same implementation every @adonis-agora
lib carries verbatim (src/crypto-kit/). No key handling of our own:
- purpose
config:secrets(one key never yields the same value for another lib); - the kit is built on AdonisJS encryption (
@adonisjs/core/encryption,@boringnode/encryption): AES-256-GCM, key rotation, purpose; the kit binds the AAD as authenticated data; - AAD = app / environment / key, so a ciphertext cannot be moved to another entry (or another app/environment) without failing to open;
- format
agora:v1:<adonis ciphertext>(or the KMS envelope); a dump has ciphertext only.
Nothing to configure: secrets use the app's own encryption service
(config/encryption.ts), so they rotate with it and an app that configures nothing keeps working.
The kit only adds the agora:v1: prefix, the purpose and the AAD binding. When there is no
encryption service (and no APP_KEY), there is no keyring and writing a secret fails loudly.
// optional: this package owns the keys instead of config/encryption.ts
defineConfig({
topology: 'control-plane',
verifyTenant,
crypto: {
keys: [
{ id: '2026-11', secret: env.get('APP_KEY_2026_11') },
{ id: 'app', secret: env.get('APP_KEY') }, // still opens old values
],
active: '2026-11',
// encryption: appEncryption, // or any Adonis-encryption-shaped instance
},
})keys may also be a plain list, newest first (keys: [nova, antiga]): the first one seals and the
kit can recognise a value sealed by an older one. active only makes sense with the
{ id, secret } form. For envelope encryption, crypto.kms is a KmsAdapter
({ wrap, unwrap }): every value carries a fresh data key wrapped by it. The kit ships an in-memory
adapter for tests and documents the real cloud adapters.
Rotating
With config/encryption.ts (the default):
- Add the new key first in
config/encryption.ts(keys: [nova, antiga]); deploy. Adonis opens old values with the old keys. - Preview:
node ace config:crypto:reseal --all --dry-run. - Run
node ace config:crypto:reseal --all— the kit cannot tell which key sealed a value, so--allrewrites every value, walking every version and the audit before/after. - Drop the old key after the reseal.
With crypto.keys:
- Add the new key first (and make it
activewhen you use ids); deploy. The kit can tell a value sealed by an older key apart (retired). - Preview:
node ace config:crypto:reseal --dry-run. - Run
node ace config:crypto:reseal— it re-sealsretired/legacyvalues only. node ace agora:doctor --deepshows noretired/legacy/unreadablevalues; then drop the old key.
Both modes walk every version and the audit before/after.
A value that cannot be re-sealed (missing key, tampering) is left untouched, counted as failed,
and makes the command exit 1 — never silently lost.
node ace agora:doctor also reports config.crypto: warn for retired/legacy values (run the
reseal), error for a value nothing can open.
The tenant's snapshot is a copy of what its token may read, written on the app host (0600). Give a
tenant config:secrets:read only when it truly needs secret values at boot; otherwise the snapshot
never holds them.
Sealed to an app
A symmetric secret is readable by the control plane (it holds the key). For a value that only one tenant app may ever read, seal it to that app's public key: the control plane writes the ciphertext and can never open it again.
Every tenant app has an X25519 key pair:
- the private key stays in the app, sealed at rest with the app encryption service (or APP_KEY when there is none), in
storage/config-tenant-key.json(mode0600,tenant.keyPathto move it); - the public key is registered with the control plane on first connect (
PUT /v1/keys) and can be inspected/rotated from the app.
node ace config:tenant:key # show the key, its kid, and what is sealed to it
node ace config:tenant:key --rotate # new key, publish it, re-seal the old values
node ace config:tenant:key --reseal # only re-seal to the active key (--dry-run to count)
node ace config:tenant:key --app=shop # on a server: list the app's public keysThen write the entry as sealed:
node ace config:entry:set stripe.secret sk_live_123 --sealed --app=shopIn the console the same thing is the seal for <app> checkbox. The value is sealed with
sealTo (the kit's ephemeral X25519 + HKDF + AES-256-GCM construction) and bound to its place with
the same AAD (config:<app>:<environment>:<key>), so it cannot be moved to another entry either.
What each side sees:
| Where | Sees |
|---|---|
| control plane store / a database dump | agora:pk1:<kid>:… ciphertext only; no code path opens it |
| console and CLI | sealed for shop; no reveal button, no config:secrets:read path |
the target app (sealedTo.app) | the plaintext, opened at boot and on reload with its private key |
| any other app | nothing: the kid has no matching private key, so the entry stays masked |
| the snapshot file | the ciphertext the server sent, never the opened value |
A token still needs config:read; config:secrets:read only decides whether the server sends the
ciphertext at all (without it the entry is masked like any other secret). The value never lands in
process.env on the server, in config:env, or in the audit trail in clear.
Rotation. --rotate creates a new key, keeps the retired private key (so old values still open),
publishes the new public key and re-seals every value sealed to the old one; it is the only side that
can, because only it can decrypt. node ace agora:doctor --deep reports the key state
(config.tenant-key): a missing keyring, an unregistered key, sealed values still on a retired key,
or values that do not open.
An app without an encryption key (config/encryption.ts or APP_KEY) cannot hold a private key: sealed values stay masked and the doctor warns.
Set tenant.keyPath: false only for an app that never receives sealed secrets.
Vault references
A value can be a reference resolved when it is read:
{ key: 'stripe.secret', value: 'vault://aws/prod/streaming#stripe_key', secret: true }defineConfig({
topology: 'control-plane',
verifyTenant,
vault: {
async resolve({ provider, path, field }) {
// authkit's vault packages, AWS Secrets Manager, HashiCorp Vault, …
return mySecretManager.read(`${provider}:${path}`, field)
},
},
})The reference is stored; the resolved value is not. A reference that cannot be resolved is served
masked: true and logged — never as a wrong or empty value.
Who may read a secret
| Caller | Needs | Gets |
|---|---|---|
a tenant with config:read | — | masked: true, no value, the vault reference still visible |
a tenant with config:secrets:read | config:read too | the decrypted value, or the vault-resolved value |
| the console | its authorize gate; an explicit reveal, audited | the value |
| the CLI / an MCP read | --secrets on get/env/pull, or revealSecrets for MCP; audited per key | the value |
The masked entry carries no value key at all, so a client cannot confuse "you may not read this"
with "this is empty".
The audit trail
{
"actor": "ann@example.com",
"action": "reveal",
"key": "stripe.secret",
"version": 7,
"at": "2026-11-14T18:00:00.000Z"
}set and unset rows keep before/after entries, themselves sealed. A reveal row records who read
which secret at which version.