Lux Docs

Dynamic Secrets

Ephemeral database credentials

Dynamic secrets are short-lived credentials generated on demand. They are automatically revoked after their TTL expires, eliminating the risk of credential sprawl.

Supported Backends

BackendDescriptionMin TTLMax TTL
PostgreSQLDynamic database users with configurable roles1m24h
MySQLEphemeral credentials with automatic cleanup1m24h
MongoDBScoped database access with TTL1m24h
RabbitMQDynamic vhost permissions1m12h

How It Works

  1. Application requests credentials from KMS
  2. KMS creates a temporary database user with scoped permissions
  3. Application uses the credentials for the TTL duration
  4. KMS automatically revokes the user when TTL expires

PostgreSQL Example

Configure the Backend

curl -X POST https://kms.lux.network/api/v1/dynamic-secrets/postgres \
  -H "Authorization: Bearer $KMS_TOKEN" \
  -d '{
    "name": "app-db",
    "host": "db.internal",
    "port": 5432,
    "database": "myapp",
    "adminUser": "kms_admin",
    "adminPassword": "<from-kms>",
    "defaultTTL": "1h",
    "maxTTL": "24h",
    "creationStatement": "CREATE ROLE \"{{username}}\" WITH LOGIN PASSWORD '\''{{password}}'\'' VALID UNTIL '\''{{expiration}}'\''; GRANT SELECT, INSERT, UPDATE ON ALL TABLES IN SCHEMA public TO \"{{username}}\";"
  }'

Request Credentials

curl -X POST https://kms.lux.network/api/v1/dynamic-secrets/postgres/app-db/lease \
  -H "Authorization: Bearer $KMS_TOKEN" \
  -d '{"ttl": "2h"}'

Response:

{
  "leaseId": "lease-abc123",
  "username": "kms_dyn_abc123",
  "password": "randomSecurePassword",
  "expiresAt": "2026-03-22T14:00:00Z"
}

Revoke Early

curl -X DELETE https://kms.lux.network/api/v1/dynamic-secrets/leases/lease-abc123 \
  -H "Authorization: Bearer $KMS_TOKEN"

Benefits

  • No long-lived database passwords
  • Automatic cleanup of unused credentials
  • Each application instance gets unique credentials
  • Full audit trail of credential usage

On this page