Vault config
vault_config
¶
Patches provider config files to route API traffic through the vault.
Applies shared_config_patch from the YAML roster after authentication
and — crucially — on every task start. Writes vault URLs / socket paths
(not secrets) to provider config files so agents route traffic through the
vault instead of hitting upstream directly with phantom tokens.
Two template tokens are substituted into patch values:
{vault_url}— HTTP URL the container should reach the vault on.{vault_socket}— filesystem path of a Unix socket the container can connect to for the vault.
The concrete values are mode-dependent (socket vs TCP transport) and resolved centrally — agent YAMLs only need to reference the tokens.
ConfigPatchError
¶
Bases: RuntimeError
Raised when a shared config patch fails and the task must not start.
VaultLocation(url, socket)
dataclass
¶
Container-side addresses of the vault in both transports.
One or both fields are set depending on the active transport:
- Socket mode: socket points at the mounted host socket; url points at the in-container TCP→UNIX loopback bridge for HTTP-only clients.
- TCP mode: url points at
host.containers.internal:<broker_port>; socket points at a local socat bridge that forwards to the same broker over TCP (for clients that can only speak HTTP-over-UNIX).
write_vault_config(provider_name)
¶
Apply shared_config_patch from the YAML roster after auth.
Patches a TOML or YAML config file in the provider's shared config dir to redirect API traffic through the vault. The patch spec is declared in the agent YAML — no provider-specific code needed.
Source code in src/terok_executor/credentials/vault_config.py
apply_shared_config_patches(roster, mounts_base, *, providers=None, disabled_providers=None)
¶
Reconcile shared_config_patch for enabled and disabled providers.
Called during task start so shared mount directories (which may have been recreated empty) always contain the correct vault addresses. Idempotent: safe to call on every launch. Disabled providers have previously managed values removed only when the live config still matches the sidecar value terok wrote last time; user-edited values are preserved and ownership is dropped.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
roster
|
AgentRoster
|
Loaded agent roster. |
required |
mounts_base
|
Path
|
Shared config mount root. |
required |
providers
|
frozenset[str] | None
|
|
None
|
disabled_providers
|
frozenset[str] | None
|
Provider subset whose previously managed patch values should
be reconciled away. |
None
|
Raises ConfigPatchError on failure — callers must not start
the container if vault routing cannot be established.
Source code in src/terok_executor/credentials/vault_config.py
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | |
resolve_vault_location(token_broker_port=None)
¶
Return the in-container vault address.
URL is always the loopback bridge on
LOOPBACK_VAULT_PORT
— the bridge runs in both transports and forwards to the
transport-specific target (host unix socket or per-container host
TCP port). token_broker_port picks the socket-facade shape for
socket-only clients: /run/terok/vault.sock in socket mode (the
bind-mounted host socket), /tmp/terok-vault.sock in TCP mode
(in-container socat unix→host-TCP).