# Configuration reference File: `~/.envbao/config.toml`, or the path in `--config` / the `ENVBAO_CONFIG` environment variable (the flag wins). Unknown keys and wrong types are rejected, so typos fail loudly. ## `[server]` | Key | Type | Default | Description | |-----|------|---------|-------------| | `address` | string | *required* | Base URL, e.g. `https://bao.example.com:8200`. No credentials in the URL. | | `token` | string | | OpenBao token. Exactly one of `token` / `token_file` is required. | | `token_file` | string | | Path (`~` expanded) to a file containing the token. Must pass the same permission policy (owner only, not a symlink). | | `namespace` | string | | Sent as `X-Vault-Namespace`. | | `ca_cert` | string | system store | PEM CA bundle used to verify the server. | | `timeout` | number | `5` | Per-request timeout in seconds. | | `allow_insecure_http` | bool | `false` | Permit `http://` to a non-loopback host. Loopback (`127.0.0.1`, `::1`, `localhost`) is always allowed over HTTP. Not recommended: the token travels in clear. | ## `[security]` | Key | Type | Default | Description | |-----|------|---------|-------------| | `allow_protected` | list of strings | `[]` | Protected variable names (see [security.md](security.md)) that secrets may set, e.g. `["PATH"]`. | | `exec_only` | bool | `false` | Refuse plain `envbao` (which prints every value) and `exec --no-redact`; only redacted `envbao exec` and `--check` work. Used by the Claude profile. | ## `[[query]]` One table per secret source. Queries run in order; later ones override earlier ones. Common keys: | Key | Type | Default | Description | |-----|------|---------|-------------| | `engine` | string | `"kv"` | Secret engine. Currently only `kv`. | | `name` | string | last `path` segment | Group name for `envbao exec -q NAME` (letters, digits, `.` `_` `-`). | | `keys` | list of strings | all | Only export these keys from the secret. | | `rename` | table | `{}` | Map secret key → variable name. Applied before `prefix`. | | `prefix` | string | `""` | Prepended to every variable name. | | `on_missing` | `"warn"` \| `"error"` | `"warn"` | What to do if the secret or a listed key does not exist. `error` aborts the whole run. | ### `engine = "kv"` | Key | Type | Default | Description | |-----|------|---------|-------------| | `mount` | string | *required* | KV mount path, e.g. `secret`. | | `path` | string | *required* | Secret path within the mount. | | `kv_version` | `1` \| `2` \| `"auto"` | `"auto"` | `auto` queries `sys/internal/ui/mounts/`; set explicitly if the token cannot read that endpoint. | Names that are not valid variable names (`[A-Za-z_][A-Za-z0-9_]*`) are skipped with a warning. ## Credential engines Besides `kv`, queries can use `engine = "database" | "aws" | "approle" | "ssh"`. They go through the same `[server]` and are filtered/renamed/prefixed like KV data. Only credential fields are exported; lease metadata is dropped. Variable names are the returned field names, so use `rename` (or `prefix`) to get the names your tools expect. ```toml [[query]] # PostgreSQL via the OpenBao database engine engine = "database" role = "readonly" # required; mount defaults to "database" # static = true # read static-creds/ instead of creating a user name = "pg" rename = { username = "PGUSER", password = "PGPASSWORD" } [[query]] engine = "aws" # role required; mount "aws"; kind = "creds" | "sts"; ttl = "15m" role = "deploy" rename = { access_key = "AWS_ACCESS_KEY_ID", secret_key = "AWS_SECRET_ACCESS_KEY", security_token = "AWS_SESSION_TOKEN" } [[query]] engine = "approle" # role required; mount "approle"; what = "both" | "role_id" | "secret_id" role = "web" [[query]] engine = "ssh" # otp (default): needs ip; sign: needs public_key_file role = "ops" ip = "10.0.0.5" ``` ### Caching dynamic credentials (`cache = true`) Dynamic credentials are created on every fetch (a new database user or IAM user each time), which would make `eval "$(envbao)"` in a shell startup file mint one per shell. Add `cache = true` to a `database` (non-`static`) or `aws` query to reuse the credential until shortly before its lease expires: ```toml [cache] store = "file" # default. "keychain" (fail if unavailable) or "auto" (keychain, else file) [[query]] engine = "database" role = "readonly" cache = true ``` * The credential is reused while more than `max(60s, 10% of the lease)` remains. After that a new one is fetched and the old lease is revoked (best effort; it expires on its own if the token may not call `sys/leases/revoke`). * Storage (`[cache] store`): `file` (default) keeps a `0600` file in `~/.envbao/cache/`; `keychain` uses the macOS Keychain (`security`) or Linux secret service (`secret-tool`) and fails if unavailable; `auto` tries the keychain and falls back to the file. Secrets are never put on a command line. * The key covers server address, namespace, engine and options; it ignores the token, so rotating the token keeps the cache valid. * `cache = true` is rejected for `kv`, `approle`, `ssh` (one-time passwords and certificates have no reusable lease) and `database` with `static = true`. * Without `cache = true`, prefer `envbao exec -q pg -- command` for dynamic engines. * `envbao --clear-cache` revokes and deletes the cached credentials. ## Adding an engine Implement `envbao.engines.Engine` (`validate` and `fetch`) in a new module under `src/envbao/engines/`, register it in `ENGINES`, and document its options here. Filtering, renaming, prefixing, name validation and rendering are shared.