Dynamic Secrets
A dynamic secret is a credential that ScaiVault generates on demand, for a specific caller, with a short lifetime. When the lifetime expires, ScaiVault automatically revokes it at the source. Compared to static credentials stored in a secret, dynamic secrets drastically reduce blast radius: if one leaks, it's valid for minutes, not months.
The mental model#
A static secret:
A dynamic secret:
Every caller gets their own short-lived credential. ScaiVault handles creation on the source system (CREATE USER, IAM policy, SSH cert) and revocation when the lease expires.
Pieces#
- Engine. A configuration pointing at a specific backend (a Postgres server, an AWS account, a GCP project). Has connection info and root credentials.
- Role. A recipe for what kind of credential to generate from an engine. Names the permissions (
SELECT ON public.*), constraints (max TTL), and any templated statements. - Lease. The result of generating credentials. Has an ID, a TTL, and the credential itself (username, password, token, etc.).
Supported engines#
| Engine | Generates | Typical TTL |
|---|---|---|
database.postgresql |
DB user with GRANT/REVOKE | 1–8h |
database.mysql |
DB user | 1–8h |
database.mongodb |
DB user | 1–8h |
database.redis |
Redis ACL user | 1–8h |
aws |
IAM access key or assumed role | 15min–12h |
azure |
Service principal | 1–8h |
gcp |
Service account key or impersonated token | 1h–3h |
ssh |
Signed SSH cert or one-time password | 5min–1h |
custom |
Whatever you script | Your call |
Creating an engine#
An engine needs root credentials for the target system. Those credentials are stored in ScaiVault itself — typically at a path protected by a narrow policy so only the engine machinery can read them.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | |
root_credentials_path points at another secret in ScaiVault. On startup, the engine reads that secret and substitutes it into connection_url. You can rotate the root creds the same way you rotate any secret — including on a rotation policy.
Defining a role#
A role says: "when someone asks for credentials from this engine with this role name, run these statements."
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | |
Template variables:
{{name}}— auto-generated username (e.g.v_readonly_a1b2c3d4).{{password}}— auto-generated password.{{expiration}}— the lease expiration in Postgres timestamp format.
Generating credentials#
An application with dynamic:generate on this engine asks for a credential:
1 2 3 4 | |
Response:
1 2 3 4 5 6 7 8 9 10 11 | |
ScaiVault:
- Picks a username (
v_<role>_<random>). - Generates a random password.
- Connects to Postgres as root, runs the creation statements.
- Issues a lease with ID
lease_abc123xyz. - Returns the credential to you.
The lease is yours for 2 hours. After that, ScaiVault connects back and runs the revocation statements — the user disappears from Postgres.
Lease lifecycle#
Renew. Extend the lease without changing the credential:
1 2 3 4 | |
Can't extend past max_ttl. After that, you must generate a new credential.
Revoke. Force immediate revocation (the credential stops working instantly):
1 2 | |
Revoke by prefix. Bulk revoke during an incident — every lease for a compromised engine, or every lease issued by a specific role:
1 2 3 4 | |
Using dynamic credentials in practice#
The idiomatic pattern:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | |
For longer-lived workers, renew before expiration instead of regenerating.
AWS, Azure, GCP engines#
AWS: ScaiVault assumes a role or creates IAM users. Configure the engine with a role ARN or an IAM user with the iam:CreateAccessKey permission. Dynamic creds are short-lived IAM keys or STS tokens.
1 2 3 4 5 6 7 8 | |
Azure / GCP: analogous. Roles specify Azure RBAC roles or GCP IAM roles.
SSH engine#
Generates signed SSH certificates or one-time passwords for SSH logins. Pairs well with an SSH CA trust on your hosts.
1 2 3 4 5 6 7 8 | |
Returns a signed OpenSSH certificate valid for 30 minutes.
What's next#
- Dynamic Secrets Guide — end-to-end setup for Postgres.
- Dynamic Reference — endpoints.
- Rotation — rotating the engine's root credentials.