Skip to content

Chatgpt auth fixes - #212

Merged
bbrowning merged 5 commits into
mainfrom
chatgpt-auth-fixes
Jul 20, 2026
Merged

Chatgpt auth fixes#212
bbrowning merged 5 commits into
mainfrom
chatgpt-auth-fixes

Conversation

@bbrowning

Copy link
Copy Markdown
Owner

This cleans up various issues with the chatgpt oauth flow for codex CLI. The refresh tokens are one-time use, so we don't do any injection of those into the container and instead expect the user to use the device code login flow to authenticate inside their paude containers.

bbrowning and others added 5 commits July 17, 2026 01:24
Replace host-seeded ~/.codex/auth.json sharing (which broke when one
session's proxy rotated a refresh token, invalidating it for others)
with an explicit --provider chatgpt opt-in: every session runs its own
codex login inside the container, and paude-proxy (bumped to
dcfc77827d09e73d418b631897347a9d9c35d9b1) captures and manages the
resulting tokens independently per session. Restricted to the local
Podman/Docker backend for now; --backend openshift is rejected since
it has no equivalent credential/injection wiring.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Codex's own `codex login` always does the ChatGPT OAuth device flow
regardless of paude's --provider flag, so a session created without
--provider chatgpt could still log in successfully while silently
missing the websocket-disabling HTTP/SSE profile and chatgpt.com
domain allowlist, since those were gated behind that explicit flag.
Flip the default so `paude create --agent codex` gets ChatGPT-plan
mode out of the box; --provider openai remains for API-key auth
(required on --backend openshift, which chatgpt mode still can't
support). Also fixes the OpenShift rejection guard to check the
resolved provider instead of the raw CLI flag, so the guard still
triggers when chatgpt is picked up implicitly.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Fresh Codex ChatGPT-plan containers get a synthetic auth.json so the
CLI never shows a login prompt, but before any session-local `codex
login` completes, paude-proxy has no real tokens to inject and every
request silently failed with a 502. paude-proxy now distinguishes
"no tokens yet" from a genuine injection failure and returns 401 for
the former, giving Codex's auth-recovery path an actionable signal
instead of an opaque gateway error.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Writing a well-formed but fake auth.json on every session start made
Codex CLI believe it was already logged in, so it skipped its own
login prompt and went straight to making API calls — which paude-proxy
had no real tokens for yet, since `codex login` had never actually run.
paude now only installs the ChatGPT provider profile TOML and leaves
auth.json alone; Codex's native login flow creates it, paude-proxy
swaps in synthetic values at the token exchange as before, and the
file then persists across stop/start of the same session since paude
no longer overwrites it.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
token_vending.go's errorResponse() helper built *http.Response values
without a Request field, which crashed goproxy with a nil pointer
dereference when the response was written back over the HTTPS/MITM
tunnel (e.g. LOGIN_SANITIZE rejecting a malformed token exchange).
All error responses now carry the originating request.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@bbrowning
bbrowning merged commit 10682cb into main Jul 20, 2026
6 checks passed
@bbrowning
bbrowning deleted the chatgpt-auth-fixes branch July 20, 2026 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant