Repository navigation
Add OpenAI workload identity federation for Codex - #75927
Conversation
Co-authored-by: pelikhan <[email protected]>
|
✅ PR Specification Reviewer completed successfully! PR Specification ReviewerOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅
|
|
✅ PR Code Quality Reviewer completed the code quality review.
|
|
✅ Test Quality Sentinel completed test quality analysis. Test Quality SentinelOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
❌ Design Decision Gate 🏗️ failed to deliver outputs during design decision gate check.
|
|
✅ Ponytail Reviewer completed successfully!
|
|
Warning The 🏗️ Design Decision Gate — ADR RequiredThis PR makes significant changes to core business logic (>100 new lines) but does not have a linked Architecture Decision Record (ADR). 📄 Draft ADR committed:
📋 What to do next
Once an ADR is linked in the PR body, this gate will re-run and verify that the implementation matches the decision. 🔎 Gate evidence
📋 Michael Nygard ADR format referenceAn ADR must contain these four sections to be considered complete:
All ADRs are stored in
|
There was a problem hiding this comment.
Reviewed the changed lines and found no high-confidence correctness or security issues that should block merge. The OpenAI WIF wiring is consistently propagated through validation, compiler environment setup, Codex startup checks, and documentation. Note: this was a static review only; tests were not run per the review constraints.
🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~4 AIC · ⌖ ~1 AIC · ⊞ 1.6K
Comment /review to run again
There was a problem hiding this comment.
What this change does: This adds OpenAI Workload Identity Federation as a Codex authentication mode and carries its configuration through compilation, the runtime harness, reflection checks, fallbacks, threat detection, tests, and docs. The keyless path is guarded by fresh AWF reflection before Codex starts.
Should fix:
-
Merge the duplicated Codex OIDC guards (
actions/setup/js/codex_harness.cjs:L607)- What this is: The Azure and OpenAI helpers perform the same environment and reflection checks, and
mainrepeats the same failure branch for each mode. - Problem: Every new OIDC mode requires edits in two wrappers and two startup branches, leaving unnecessary near-copy code in the harness.
- Fix: Parameterize one
hasCodexOIDCProxy(reflectData, env, authProvider)and useoidcAuthfor one shared startup check. - If we skip it: The two keyless paths can accumulate different checks and the harness stays needlessly larger.
- What this is: The Azure and OpenAI helpers perform the same environment and reflection checks, and
Nice to have:
-
Collapse the fallback OIDC wrapper (
pkg/workflow/engine_fallback_models.go:L125)- What this is:
usesOIDCForOpenAIonly calls the now-privateusesAzureOIDCForOpenAIhelper and adds the Codex OpenAI case afterward. - Problem: This creates an extra call layer for the fallback secret and environment paths.
- Fix: Rename the existing switch to
usesOIDCForOpenAIand addisCodexOpenAIWIF(data)in itscodexcase, then delete the wrapper. - If we skip it: The fallback policy remains split across two helpers that must change together.
- What this is:
Verdict: fix 1 first.
Lean: -10 lines possible.
Generated by ✂️ Ponytail Reviewer for #75927 · codex · routed: gpt56 max · ~5 AIC · ⌖ ~1 AIC · ⊞ 118
Comment /ponytail to run again
| return hasAzureOIDCProviderEndpoint(reflectData, "openai"); | ||
| } | ||
|
|
||
| function hasCodexOpenAIWIFProxy(reflectData, env) { |
There was a problem hiding this comment.
Should fix: This is a second copy of hasCodexAzureOIDCProxy; the two wrappers only differ in the auth-mode literal. Parameterize one hasCodexOIDCProxy(reflectData, env, authProvider) and use it for both modes so the gate cannot drift and these duplicate lines disappear.
There was a problem hiding this comment.
Fixed in e71afa3: both auth modes now use hasCodexOIDCProxy(reflectData, env, authProvider). The updated harness and reflection suites pass (367 tests).
| } | ||
|
|
||
| func usesOIDCForOpenAI(data *WorkflowData) bool { | ||
| return usesAzureOIDCForOpenAI(data) || data != nil && data.EngineConfig != nil && |
There was a problem hiding this comment.
Nice to have: usesOIDCForOpenAI adds a wrapper around a private helper that now has only one caller. Fold the OpenAI case into that existing switch (and rename it to usesOIDCForOpenAI) to remove the extra layer and keep Codex/Pi fallback policy in one place.
There was a problem hiding this comment.
Fixed in e71afa3: folded Codex OpenAI WIF into the existing Codex/Pi switch and renamed it usesOIDCForOpenAI, removing the wrapper.
There was a problem hiding this comment.
Skills-Based Review 🧠
Applied /diagnosing-bugs, /tdd, and /codebase-design. Requesting changes: two validation gaps can silently produce the wrong auth path.
📋 Key Themes and Highlights
Key Themes
- Silent fallback to static key: with
firewall: false,provider: openaipasses validation, butisCodexOpenAIWIFreturns false andCODEX_API_KEYis still wired. A probe confirmed this. The Azure path has the same firewall gate. - Engine scoping:
validateOpenAIWIFEngineAuthdoes not restrictprovider: openaitoengine.id: codex. A probe confirmedengine.id: claudepasses and emits a secret validation step. - Test coverage: the fallback WIF branch (
usesOIDCForOpenAI) and the OpenAI reflection guard in threat detection have no Go tests. - Unrelated change:
buildPullAWFContainersStepnow splits on CR as well as LF. This is not described in the PR body. Confirm that lock output is unchanged or split it out.
Positive Highlights
- ✅ The field rename to
ServiceAccountIDis applied consistently. The JSON key is unchanged. - ✅
codexOIDCAuthModecentralizes the Azure and OpenAI mode selection cleanly. - ✅ Targeted Go tests for the WIF and validation paths pass, and gofmt is clean.
Limits of This Review
- JS tests (
awf_reflect.test.cjs,codex_harness.test.cjs) were not run.npm cifailed on a sandbox TLS certificate error, so the JS changes are unverified here. - The AWF release pinned by
DefaultFirewallVersion(v0.29.7) was not checked forgithub-oidc/openaisupport. The PR body says a compatible release is required.
@copilot please address the review comments above, starting with the firewall fallback and engine-scoping gaps.
🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · routed: haiku55 xhigh · ~8 AIC · ⌖ ~2 AIC · ⊞ 5.4K
Comment /matt to run again
| auth := workflowData.EngineConfig.Auth | ||
| return auth.Type == "github-oidc" && auth.Provider == "openai" && | ||
| auth.OpenAIIdentityProviderID != "" && auth.ServiceAccountID != "" && | ||
| auth.Audience != "" && isFirewallEnabled(workflowData) |
There was a problem hiding this comment.
[/diagnosing-bugs] With the firewall disabled, isOpenAIWIFWithAWF returns false, so the keyless path is skipped without any error. Validation still passes, and buildCodexExecutionEnv silently wires the static CODEX_API_KEY path.
💡 Suggested fix
Reject this combination in validateOpenAIWIFEngineAuth with a clear error, for example "engine.auth with provider=openai requires the firewall to be enabled". Add a regression test in codex_azure_oidc_test.go that asserts compilation fails when firewall: false is combined with OpenAI WIF. The Azure path has the same firewall gate, so consider fixing both together.
@copilot please address this.
There was a problem hiding this comment.
Fixed in e71afa3: OpenAI WIF now fails compilation when the firewall is disabled. A non-strict sandbox-opt-out regression verifies the WIF-specific error rather than a generic sandbox rejection.
| return nil | ||
| } | ||
| auth := workflowData.EngineConfig.Auth | ||
| if auth.Type != "github-oidc" || auth.Provider != "openai" { |
There was a problem hiding this comment.
[/tdd] validateOpenAIWIFEngineAuth checks only provider: openai, not engine.id: codex. A probe confirmed that engine.id: claude with provider: openai passes validation and emits a secret validation step. The schema accepts openai without an engine constraint, so this validator is the only guard.
💡 Suggested test and fix
Add an engine check that rejects provider: openai for non-codex engines. Then add a table-driven test in codex_azure_oidc_test.go covering codex (accepted) and claude (rejected).
@copilot please address this.
There was a problem hiding this comment.
Fixed in e71afa3: validation requires Codex and the OpenAI inference provider. Compilation tests cover accepted Codex auth and rejected Claude/GitHub-inference configurations.
| func codexAzureOIDCReflectionGuard() string { | ||
| script := `fetch("http://api-proxy:10000/reflect", { signal: AbortSignal.timeout(60000) }).then(async response => { | ||
| func codexOIDCReflectionGuard(provider string) string { | ||
| script := fmt.Sprintf(`fetch("http://api-proxy:10000/reflect", { signal: AbortSignal.timeout(60000) }).then(async response => { |
There was a problem hiding this comment.
[/diagnosing-bugs] provider is interpolated into the JavaScript source with fmt.Sprintf before shell escaping. The only callers today pass azure or openai, so this is safe now, but it is fragile: a future provider string containing a quote or backtick would break the generated script.
💡 Suggested fix
Pass a fixed label instead of config-derived text. For example, select between two literal guard strings in the caller, so the JS template never receives user-controlled values.
@copilot please address this.
There was a problem hiding this comment.
Fixed in e71afa3: the auth type and error message are encoded as quoted literals before insertion into JavaScript, then the script is shell-escaped. Added a quote-containing provider regression.
| } | ||
| } | ||
|
|
||
| func usesOIDCForOpenAI(data *WorkflowData) bool { |
There was a problem hiding this comment.
[/tdd] usesOIDCForOpenAI now skips the fallback OpenAI secret name and env for Codex WIF, but no test covers this branch. The only fallback test is the Pi Azure case, so a regression here would pass unnoticed.
💡 Suggested test
Add a case to engine_fallback_models_test.go with codex, provider: openai WIF, and a configured fallback model. Assert that fallbackProviderSecretNames omits the OpenAI key and that applyFallbackProviderEnv does not set it.
@copilot please address this.
There was a problem hiding this comment.
Fixed in e71afa3: added Codex OpenAI WIF fallback coverage for omitted secret names, omitted API-key environment variables, preserved keyless auth, and an Anthropic fallback retaining its key.
|
|
||
| // Split the generated YAML into individual lines so each is a separate entry | ||
| lines := strings.Split(b.String(), "\n") | ||
| lines := strings.FieldsFunc(b.String(), func(r rune) bool { return r == '\n' || r == '\r' }) |
There was a problem hiding this comment.
[/codebase-design] The change from strings.Split to strings.FieldsFunc in buildPullAWFContainersStep is unrelated to WIF and is not mentioned in the PR description. Its only behavior change is that CR is now treated as a separator. Empty entries were already skipped by the existing line != "" check.
💡 Suggested fix
Move this into its own PR, or call it out in the description with a test. Confirm that existing .lock.yml output is byte-identical after the change.
@copilot please address this.
There was a problem hiding this comment.
Fixed in e71afa3: removed CR normalization and restored the original LF-only behavior. Uses strings.Lines with LF trimming because latest main's linter rejects newline strings.Split; empty entries remain skipped.
| if engineID == "codex" && isCodexAzureOIDC(threatDetectionData) { | ||
| npmPathSetup += " && " + codexAzureOIDCReflectionGuard() | ||
| if engineID == "codex" && (isCodexAzureOIDC(threatDetectionData) || isCodexOpenAIWIF(threatDetectionData)) { | ||
| npmPathSetup += " && " + codexOIDCReflectionGuard(threatDetectionData.EngineConfig.Auth.Provider) |
There was a problem hiding this comment.
[/tdd] No test asserts that the threat-detection step emits codexOIDCReflectionGuard for OpenAI WIF. The new github-oidc/openai check string and error message are unverified by Go tests, and the JS guard tests were not run in this review.
💡 Suggested test
Add a step-generation test for engine.id: codex with provider: openai WIF. Assert that the generated script contains github-oidc/openai. This guard is the only runtime proof that the proxy is using OIDC, so it needs coverage.
@copilot please address this.
There was a problem hiding this comment.
Fixed in e71afa3: the compiled detection-job test asserts the fresh reflection URL, github-oidc/openai, and its guard error message, plus omitted static-key configuration. Focused Go tests and all 367 harness/reflection JS tests pass.
There was a problem hiding this comment.
🟡 Changes recommended
The pinned AWF v0.29.7 does not forward the required OpenAI WIF identifiers, causing default-generated workflows to fail at startup.
5 open issues
Require an AWF version that forwards OpenAI WIF identifiers · New Allowlist auth.openai.com in the OpenAI WIF example · New Validate explicit threat-detection engine auth · New Preserve auth.openai.com in agent and detection allowlists · New Derive detection-job OIDC permission from detector auth · New
What changed in this PR
Adds support in gh-aw for Codex to authenticate to OpenAI through the AWF API proxy using GitHub OIDC, without a long-lived API key.
Changes:
- Adds OpenAI federation configuration, required-field validation, schema support, and editor completions.
- Extends keyless Codex authentication and fresh reflection checks to execution, fallback models, and threat detection.
- Adds authentication tests and configuration documentation.
| File | Description |
|---|---|
pkg/workflow/threat_detection_external.go |
Extends keyless detector configuration and reflection guards. |
pkg/workflow/openai_oidc.go |
Identifies OpenAI WIF configurations using AWF. |
pkg/workflow/engine.go |
Adds identity fields and proxy environment mappings. |
pkg/workflow/engine_fallback_models.go |
Skips static OpenAI keys for WIF fallbacks. |
pkg/workflow/engine_config_test.go |
Tests OpenAI authentication parsing and environment mappings. |
pkg/workflow/compiler_validators.go |
Validates required OpenAI federation fields. |
pkg/workflow/compiler_orchestrator_engine_test.go |
Updates assertions for the shared service-account field. |
pkg/workflow/codex_engine.go |
Selects keyless OpenAI authentication during execution. |
pkg/workflow/codex_config.go |
Omits static-key configuration for OpenAI WIF. |
pkg/workflow/codex_azure_oidc_test.go |
Adds OpenAI WIF authentication and compilation tests. |
pkg/parser/schemas/main_workflow_schema.json |
Defines OpenAI provider and identity configuration. |
docs/src/content/docs/reference/glossary.md |
Expands authentication terminology to include OpenAI WIF. |
docs/src/content/docs/reference/frontmatter-full.md |
Documents the new provider and identity field. |
docs/src/content/docs/reference/auth.mdx |
Adds OpenAI federation setup and runtime requirements. |
docs/public/editor/autocomplete-data.json |
Adds OpenAI authentication completions. |
actions/setup/js/codex_harness.test.cjs |
Tests OpenAI WIF startup and endpoint checks. |
actions/setup/js/codex_harness.cjs |
Requires matching fresh reflection before WIF startup. |
actions/setup/js/awf_reflect.test.cjs |
Tests provider-specific OIDC endpoint validation. |
actions/setup/js/awf_reflect.cjs |
Generalizes OIDC reflection checks across providers. |
Review effort: Max (auto)
| if len(missing) > 0 { | ||
| return fmt.Errorf("engine.auth with provider=openai requires the following fields: %s", strings.Join(missing, ", ")) | ||
| } | ||
| return nil |
| network: | ||
| allowed: | ||
| - defaults | ||
| - api.openai.com |
| if err := validateGCPWIFEngineAuth(workflowData); err != nil { | ||
| return err | ||
| } | ||
| return validateOpenAIWIFEngineAuth(workflowData) |
| if engineID == "codex" && (isCodexAzureOIDC(threatDetectionData) || isCodexOpenAIWIF(threatDetectionData)) { | ||
| npmPathSetup += " && " + codexOIDCReflectionGuard(threatDetectionData.EngineConfig.Auth.Provider) |
| if engineID == "codex" && (isCodexAzureOIDC(threatDetectionData) || isCodexOpenAIWIF(threatDetectionData)) { | ||
| npmPathSetup += " && " + codexOIDCReflectionGuard(threatDetectionData.EngineConfig.Auth.Provider) |
|
Copilot assignment requested for the following outstanding work:
Once you start work, post this work summary as a PR comment without the leading Copilot mention, including the Sous-chef head, work, and state lines below, to record that the assignment is running. Apply the necessary fixes on this PR's existing branch, reply to each listed review thread and resolve it when addressed. Ignore feedback already answered or resolved; stop when only human review or CI remains. Do not merge or trigger CI. Sous-chef requested-head: f492e0d
|
Assignment running:
Sous-chef requested-head: f492e0d |
…e-auth-provider-openai Co-authored-by: gh-aw-bot <[email protected]>
Co-authored-by: gh-aw-bot <[email protected]>
|
🎉 This pull request is included in a new release. Release: |


Codex workflows calling the OpenAI API currently require a long-lived API key. This adds
engine.auth.provider: openaito configure GitHub OIDC-based authentication through the AWF API proxy.Requires an AWF API-proxy release that supports OpenAI WIF.