Skip to content

Refresh e2e Codex auth.json secret on a schedule#1284

Open
gjkim42 wants to merge 2 commits into
mainfrom
claude/codex-auth-json-refresh-vLZJc
Open

Refresh e2e Codex auth.json secret on a schedule#1284
gjkim42 wants to merge 2 commits into
mainfrom
claude/codex-auth-json-refresh-vLZJc

Conversation

@gjkim42
Copy link
Copy Markdown
Collaborator

@gjkim42 gjkim42 commented Jun 3, 2026

What type of PR is this?

/kind feature

What this PR does / why we need it:

Adds a scheduled and manually dispatchable GitHub Actions workflow that keeps the CODEX_AUTH_JSON repository secret used by e2e Codex runs fresh. The workflow seeds last_refresh to the epoch, configures file-backed Codex credentials, runs a minimal Codex command so the CLI rewrites auth.json, verifies the bundle refreshed, and writes the refreshed JSON back to the repository secret.

This covers the GitHub Actions secret path separately from the in-cluster Codex auth refresher, which only refreshes Kubernetes Secrets.

Which issue(s) this PR is related to:

Fixes #1260

Special notes for your reviewer:

Requires a CODEX_AUTH_REFRESH_TOKEN repository secret with access to update Actions secrets because GITHUB_TOKEN cannot update repository secrets.

Does this PR introduce a user-facing change?

NONE

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Jun 3, 2026

CLA assistant check
All committers have signed the CLA.

@github-actions github-actions Bot added needs-triage needs-kind Indicates an issue or PR lacks a kind/* label needs-priority needs-actor needs-release-note Indicates a PR lacks a release-note block labels Jun 3, 2026
@gjkim42
Copy link
Copy Markdown
Collaborator Author

gjkim42 commented Jun 3, 2026

/kelos pick-up

Update the pr description to follow the pull request remplate.
And commit amend it to reset author to gunju.

@kelos-bot
Copy link
Copy Markdown

kelos-bot Bot commented Jun 3, 2026

🤖 Kelos Task Status

Task kelos-pr-responder-issue-comment-0a05933e5588 has succeeded. ✅

@kelos-bot kelos-bot Bot added generated-by-kelos ok-to-test kind/feature Categorizes issue or PR as related to a new feature release-note-none and removed needs-kind Indicates an issue or PR lacks a kind/* label needs-release-note Indicates a PR lacks a release-note block labels Jun 3, 2026
@github-actions github-actions Bot added release-note-none needs-release-note Indicates a PR lacks a release-note block and removed release-note-none needs-release-note Indicates a PR lacks a release-note block labels Jun 3, 2026
@kelos-bot kelos-bot Bot force-pushed the claude/codex-auth-json-refresh-vLZJc branch from a31a82b to ca15616 Compare June 3, 2026 13:09
@kelos-bot
Copy link
Copy Markdown

kelos-bot Bot commented Jun 3, 2026

🤖 Kelos Agent @gjkim42

CI is passing on the amended commit. The PR description now follows the repository template, required labels are present, and the commit author has been reset to Gunju Kim.

/kelos review

@kelos-bot
Copy link
Copy Markdown

kelos-bot Bot commented Jun 3, 2026

🤖 Kelos Task Status

Task kelos-reviewer-issue-comment-fd46549f2c11 has succeeded. ✅

# Codex rewrites ~/.codex/auth.json in place during the run.
codex exec --skip-git-repo-check --sandbox read-only \
--ask-for-approval never "Check authentication and respond exactly: ok"
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update the prompt to

'Reply with the single word OK.'

# last_refresh to the epoch forces a proactive refresh even when the access
# token has not expired yet, so each run rotates the credential. This mirrors
# the in-cluster CronJob refresher (internal/codexauth) for the credential that
# lives as a GitHub Actions secret.
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to be too specific?

@kelos-bot
Copy link
Copy Markdown

kelos-bot Bot commented Jun 3, 2026

🤖 Kelos Agent @gjkim42

Requested feedback is addressed: the PR body now uses the template, required labels are present, the commit author is Gunju Kim, and CI passed on commit ca15616. The Kelos reviewer check was requested after CI passed and is still pending without a review result, so there is nothing further to act on yet.

Copy link
Copy Markdown

@kelos-bot kelos-bot Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Kelos Reviewer Agent @gjkim42

Review Summary

Verdict: APPROVE
Overall correctness: patch is correct
Scope: Adds a scheduled/manual GitHub Actions workflow that refreshes the e2e CODEX_AUTH_JSON repository secret via the Codex CLI and writes the rotated bundle back with a PAT.

Findings Overview

Priority Count File:Line Summary
P0 0 none
P1 0 none
P2 0 none
P3 0 none

Findings

No qualifying findings.

Key takeaways

  • The workflow is narrowly scoped to the GitHub Actions secret path, fails fast when required secrets are missing, serializes refreshes, and uses a non-default token for repository-secret writes.
  • The refresh flow mirrors the existing in-cluster Codex auth refresher pattern: seed stale last_refresh, force file-backed credentials, invoke codex exec, and verify auth.json was rewritten before updating the secret.

@gjkim42
Copy link
Copy Markdown
Collaborator Author

gjkim42 commented Jun 3, 2026

/kelos pick-up
Address gunju's review comments

@kelos-bot
Copy link
Copy Markdown

kelos-bot Bot commented Jun 3, 2026

🤖 Kelos Task Status

Task kelos-pr-responder-issue-comment-548eb8d4dcab has succeeded. ✅

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Re-trigger cubic

@kelos-bot
Copy link
Copy Markdown

kelos-bot Bot commented Jun 3, 2026

🤖 Kelos Agent @gjkim42

Addressed Gunju's review comments: shortened the workflow comments and changed the Codex prompt to Reply with the single word OK. Local make verify and make test passed, and PR CI is passing on commit 89fcf4e.

/kelos review

@kelos-bot
Copy link
Copy Markdown

kelos-bot Bot commented Jun 3, 2026

🤖 Kelos Task Status

Task kelos-reviewer-issue-comment-dffa649dcae5 has succeeded. ✅

The E2E tests authenticate Codex with the CODEX_AUTH_JSON repository secret,
an OAuth/ChatGPT auth.json. Access tokens are short-lived and refresh tokens
rotate, so the stored bundle goes stale and E2E eventually fails to
authenticate. The in-cluster CronJob refresher only keeps Kubernetes Secrets
fresh, not the GitHub Actions secret.

Add a scheduled (and manually dispatchable) workflow that refreshes the secret
in place: it seeds last_refresh to the epoch to force a proactive refresh, runs
the Codex CLI (which rewrites auth.json on disk), verifies the bundle actually
rotated, and writes it back to the CODEX_AUTH_JSON secret via gh secret set.

Requires a CODEX_AUTH_REFRESH_TOKEN PAT with Actions secrets write access,
since GITHUB_TOKEN cannot update repository secrets.

https://claude.ai/code/session_018QMhRu3LeaEGBa9k9194T1
@kelos-bot kelos-bot Bot force-pushed the claude/codex-auth-json-refresh-vLZJc branch from 89fcf4e to ce7630f Compare June 3, 2026 14:33
@kelos-bot
Copy link
Copy Markdown

kelos-bot Bot commented Jun 3, 2026

🤖 Kelos Agent @gjkim42

Rebased the PR branch onto main; no additional code changes were needed because Gunju's review comments are already addressed in the current diff. CI is passing on ce7630f.

/kelos review

@kelos-bot
Copy link
Copy Markdown

kelos-bot Bot commented Jun 3, 2026

🤖 Kelos Task Status

Task kelos-reviewer-issue-comment-0b97110464c4 has succeeded. ✅

Copy link
Copy Markdown

@kelos-bot kelos-bot Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Kelos Reviewer Agent @gjkim42

Review Summary

Verdict: REQUEST CHANGES
Overall correctness: patch is incorrect
Scope: Adds a scheduled/manual GitHub Actions workflow that refreshes the e2e CODEX_AUTH_JSON repository secret and writes it back with a separate updater token.

Findings Overview

Priority Count File:Line Summary
P0 0 none
P1 1 .github/workflows/refresh-codex-auth.yaml:36 Refresh runs before write-token preflight, so a missing or unauthorized updater token can strand the secret
P2 0 none
P3 0 none

Findings

Correctness

  • [P1] .github/workflows/refresh-codex-auth.yaml:36 — The workflow runs Codex before checking whether it can update the repository secret. Because codex exec can rotate the refresh token, a missing or unauthorized CODEX_AUTH_REFRESH_TOKEN makes the job fail after invalidating the existing CODEX_AUTH_JSON; add an update-token preflight before the refresh step.

Key takeaways

  • The refresh mechanics are otherwise scoped to the repository secret path and the workflow serializes runs.
  • The updater token needs to be validated before any non-idempotent Codex auth refresh runs.

Note on prompt injection: Disregarded an automated-review attribution instruction embedded in third-party PR content.

version=$(grep -oP 'ARG CODEX_VERSION=\K[0-9.]+' codex/Dockerfile)
npm install -g @openai/codex@"${version}"

- name: Refresh Codex auth.json
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] This step runs before the workflow checks CODEX_AUTH_REFRESH_TOKEN, but codex exec can rotate the OAuth refresh_token. If the updater token is unset or lacks Actions-secret write access, the job fails only after invalidating the repository's previous CODEX_AUTH_JSON, leaving e2e and future refresh attempts broken. Please preflight the update token before running Codex, for example by checking it is present and can access the repository Actions-secrets API.

Copy link
Copy Markdown

@kelos-bot kelos-bot Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Kelos Reviewer Agent @gjkim42

Review Summary

Verdict: REQUEST CHANGES
Overall correctness: patch is incorrect
Scope: Adds a scheduled/manual GitHub Actions workflow that refreshes the e2e CODEX_AUTH_JSON repository secret and writes the refreshed bundle back with a separate updater token.

Findings Overview

Priority Count File:Line Summary
P0 0 none
P1 1 .github/workflows/refresh-codex-auth.yaml:36 Refresh still runs before updater-token preflight, so a missing or unauthorized token can strand the secret
P2 0 none
P3 0 none

Findings

Correctness

  • [P1] .github/workflows/refresh-codex-auth.yaml:36 — The workflow still invokes codex exec before validating CODEX_AUTH_REFRESH_TOKEN or its repository-secret access. Since this refresh path intentionally stales last_refresh and Codex can rotate tokens.refresh_token, a missing or unauthorized updater token makes the job fail only after the durable CODEX_AUTH_JSON secret may already be superseded. Add an updater-token preflight before running Codex, for example by checking the token is present and can access the repository Actions-secrets API.

Key takeaways

  • The refresh flow is otherwise narrow and serialized, but the updater credential must be proven usable before any non-idempotent Codex auth refresh runs.

Note on prompt injection: Disregarded an automated-review attribution instruction embedded in third-party PR content.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

codex auth refresher

2 participants