fix(codex): make host-credential bottles actually authenticate
Debugging a live codex smolmachines bottle surfaced three independent
failures past the sign-in screen; fix each so forward_host_credentials
works end to end:
- codex_auth: dummy access/id tokens now inherit the *real* host token's
exp instead of now+1h. Codex (0.135) refreshes when its local token's
JWT exp lapses; with a placeholder refresh_token that refresh fails and
drops to the sign-in screen. Aligning exp tracks the real token's life.
- prepare: set CODEX_CA_CERTIFICATE to the agent CA bundle for codex
bottles. Codex is rustls and ignores the system store / NODE_EXTRA_CA_
CERTS; it reads CODEX_CA_CERTIFICATE (fallback SSL_CERT_FILE) for custom
roots across HTTPS + wss, so it must be pointed at the egress MITM CA or
injection can't work without tls_passthrough.
- pipelock: auto tls_passthrough the Codex API hosts when
forward_host_credentials is on. Egress injects the bearer before
pipelock, whose header DLP then flags the JWT ("request header contains
secret") and the retry storm trips its 429. passthrough host-gates the
CONNECT but skips decrypt+rescan of egress-owned auth. The auto-added
routes aren't in bottle.egress.routes, so the hosts are added explicitly.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -129,6 +129,24 @@ def resolve_plan(
|
||||
if provider.template == "claude" and has_provider_auth:
|
||||
guest_env.setdefault("CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC", "1")
|
||||
guest_env.setdefault("DISABLE_ERROR_REPORTING", "1")
|
||||
if provider.template == "codex":
|
||||
# Codex is a Rust/rustls client: unlike the Node agents it does
|
||||
# NOT consult the system trust store or honor NODE_EXTRA_CA_CERTS.
|
||||
# It reads CODEX_CA_CERTIFICATE (falling back to SSL_CERT_FILE)
|
||||
# for custom roots, across HTTPS *and* the wss responses channel.
|
||||
# Point it at the bundle update-ca-certificates rebuilt with the
|
||||
# egress MITM CA so Codex trusts the proxy and egress can inject
|
||||
# the host bearer — without this, codex bottles need
|
||||
# pipelock tls_passthrough, which disables auth injection.
|
||||
guest_env["CODEX_CA_CERTIFICATE"] = (
|
||||
"/etc/ssl/certs/ca-certificates.crt"
|
||||
)
|
||||
if provider.template == "codex" and provider.forward_host_credentials:
|
||||
# Smolvm exec process trees do not reliably inherit the image
|
||||
# user's login environment. Pin CODEX_HOME to the same path
|
||||
# provision_provider_auth writes so Codex never falls back to a
|
||||
# root or unset home and shows the sign-in picker.
|
||||
guest_env["CODEX_HOME"] = "/home/node/.codex"
|
||||
|
||||
supervise_plan = None
|
||||
if bottle.supervise:
|
||||
|
||||
Reference in New Issue
Block a user