Repository navigation
Support Azure Entra OIDC in native Codex - #68457
Conversation
Co-authored-by: pelikhan <[email protected]>
Co-authored-by: pelikhan <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
Default external threat detection still requires CODEX_API_KEY and bypasses the new reflection guard.
1 open finding
What changed in this PR
Adds keyless Azure Entra OIDC support for native Codex through the AWF proxy.
Changes:
- Suppresses API-key requirements and validates fresh proxy reflection.
- Extends keyless handling to fallbacks and detection.
- Adds tests and authentication documentation.
| File | Description |
|---|---|
pkg/workflow/engine_fallback_models.go |
Skips OpenAI fallback secrets for Azure OIDC. |
pkg/workflow/codex_engine.go |
Adds keyless authentication policy and environment handling. |
pkg/workflow/codex_config.go |
Omits env_key in OIDC proxy configuration. |
pkg/workflow/codex_azure_oidc_test.go |
Adds compiler and fallback coverage. |
actions/setup/js/codex_harness.cjs |
Adds reflection-based startup validation. |
actions/setup/js/codex_harness.test.cjs |
Tests keyless startup and failure cases. |
docs/src/content/docs/reference/auth.mdx |
Documents Entra OIDC configuration. |
docs/src/content/docs/reference/engines.md |
Lists OIDC as a Codex authentication option. |
go.sum |
Removes obsolete dependency checksums. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
| if isCodexAzureOIDC(workflowData) { | ||
| // Non-secret launch policy; the harness also verifies fresh AWF reflection. | ||
| env["GH_AW_CODEX_OIDC_AUTH"] = "azure" | ||
| } |
There was a problem hiding this comment.
External Codex detection now omits env_key for Azure OIDC and runs a fresh /reflect gate inside AWF before threat-detect. Fixed in ca2b637.
|
✅ Ponytail Reviewer completed successfully! Ponytail 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. ✅
|
|
✅ 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 🏗️ completed the design decision gate check. See the comment below for the result and any generated ADR draft. Commit pushed:
|
|
✅ PR Code Quality Reviewer completed the code quality review.
|
🏗️ Design Decision Gate — ADR RequiredThis PR makes significant changes to core business logic (173 new lines in 📄 Draft ADR committed:
🔍 Evidence used
📋 What to do next
Once an ADR is linked in the PR body, this gate will re-run and verify the implementation matches the decision. ❓ Why ADRs MatterADRs create a searchable, permanent record of why the codebase looks the way it does — especially for security-sensitive decisions like moving from static API keys to federated credentials. Future contributors (and your future self) will thank you. 📋 Michael Nygard ADR Format ReferenceAn ADR must contain these four sections to be considered complete:
All ADRs are stored in
|
Comment MemoryPeek at saved memory (pr-code-quality-reviewer)Note This comment is managed by comment memory.Expand the saved memory block to view or edit the persistent context for this thread.
|
There was a problem hiding this comment.
Request changes
The Azure OIDC support is close, but I still see a real startup-path correctness risk and the detector coverage is not strong enough to prove the advertised keyless flow works outside the main Codex harness.
Blocking themes
- The new
hasCodexAzureOIDCProxy()guard does not reuse the same endpoint-resolution path as the later Codex provider configuration, so valid alias-normalized OpenAI endpoints can be rejected or the two code paths can drift. - The threat-detection claim is still under-tested: counting
GH_AW_CODEX_OIDC_AUTH: azurein generated YAML does not prove the detector-side Codex configuration can actually authenticate without static OpenAI credentials.
Those are both in the critical path for a feature whose main promise is "keyless Codex via Azure OIDC".
🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt54 · 35.7 AIC · ⌖ 5.8 AIC · ⊞ 21.3K
Comment /review to run again
| assert.Contains(t, lock, "--exclude-env ACTIONS_ID_TOKEN_REQUEST_TOKEN") | ||
| assert.Contains(t, lock, "--exclude-env ACTIONS_ID_TOKEN_REQUEST_URL") | ||
| // The detector must inherit the same keyless execution policy. | ||
| assert.GreaterOrEqual(t, strings.Count(lock, "GH_AW_CODEX_OIDC_AUTH: azure"), 2) |
There was a problem hiding this comment.
This assertion only counts an env flag in the compiled YAML, so it can pass even when the threat-detection path still cannot authenticate keylessly.
💡 Why this matters
The change is claiming inherited threat-detection support, but this test never proves that the detector gets a usable Codex provider configuration or can run without CODEX_API_KEY/OPENAI_API_KEY. Counting GH_AW_CODEX_OIDC_AUTH: azure occurrences is too indirect for a security-sensitive auth path.
Fix snippet: assert on the generated detector configuration or the detection execution step directly, for example by verifying the detector-side Codex config omits env_key and still resolves the managed proxy base URL.
Without an end-to-end detector assertion, this PR can stay green while the first threat-detection run still dies on missing credentials.
There was a problem hiding this comment.
Replaced the env-count check with assertions for detector-side keyless config, the Azure OIDC env, and the fresh reflection gate. Fixed in ca2b637.
| * @param {NodeJS.ProcessEnv} env | ||
| * @returns {boolean} | ||
| */ | ||
| function hasCodexAzureOIDCProxy(reflectData, env) { |
There was a problem hiding this comment.
This guard reimplements endpoint selection and then hard-codes endpoint.provider === "openai", so any reflect alias that the resolver accepts will still be rejected here and keyless Codex will fail to start.
💡 Why this matters
configureCodexProviderFromReflect() uses the shared resolver, but this safety gate scans reflectData.endpoints itself and only accepts the raw provider string openai. That means a valid alias-normalized OpenAI endpoint can be rejected up front here, and the two code paths can drift on selection rules over time.
Fix snippet: const resolved = resolveProviderEndpointFromReflect(...); return normalizeReflectProviderName(resolved?.endpoint?.provider) === "openai" && resolved?.endpoint?.auth_type === "github-oidc/azure";
Reusing the same resolver keeps the startup check and the actual provider rewrite on one selection path instead of hoping two different scans stay equivalent.
There was a problem hiding this comment.
The startup guard now uses the shared endpoint resolver and checks its normalized selected provider; a normalized-alias harness test covers it. Fixed in ca2b637.
There was a problem hiding this comment.
Skills-Based Review 🧠
Applied /diagnosing-bugs, /tdd, and /codebase-design — requesting changes: the keyless-Codex fix does not cover the default external threat-detection path, and Azure WIF config has no compile-time validation.
📋 Key Themes & Highlights
Key Themes
- Incomplete fix scope (highest severity):
buildExternalDetectorCodexConfig(pkg/workflow/threat_detection_external.go) — the code path used by the default (external/threat-detectbinary) threat-detection job — still hardcodesenv_key = "CODEX_API_KEY"and performs no/reflectfreshness check. This directly contradicts the PR description's claim ("Extend keyless behavior to inherited threat detection"). A prior reviewer flagged the same gap oncodex_engine.go:524; it's still open in this diff. - Missing input validation:
isCodexAzureOIDCdoesn't verifyazure-tenant-id/azure-client-idare set, unlike the existingvalidateGCPWIFEngineAuthpattern used for Gemini's GCP WIF. Misconfigured workflows will compile successfully and fail only at runtime with an opaque error. - Minor dead-code smell: a redundant
ifinconfigureCodexProviderFromReflectafter an equivalent early return.
Positive Highlights
- ✅ The core harness guard (
hasCodexAzureOIDCProxy) correctly requires fresh reflection data and rejects persisted/stale reflect output — addresses a real TOCTOU concern. - ✅ Good test coverage in
codex_harness.test.cjsandcodex_azure_oidc_test.gofor the main agent-job path (static-key proxy, wrong OIDC provider, disabled reflection, missing config). - ✅ Fallback-model secret suppression (
engine_fallback_models.go) correctly mirrors the existing Anthropic WIF pattern. - ✅ Clear, well-structured documentation addition in
auth.mdxwith a concreteaw wrapexample.
Investigation note: reviewed the full diff directly (586-line patch, well within budget); no triage/sub-agent was needed given the diff's manageable size and clear file boundaries.
@copilot please address the review comments above.
🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · sonnet50 · 200.6 AIC · ⌖ 16.2 AIC · ⊞ 10.3K
Comment /matt to run again
| const tomlContent = fs.readFileSync(codexConfigPath, "utf8"); | ||
| const providerSectionPattern = /\[model_providers\.openai-proxy\][\s\S]*?(?=\n\[|$)/; | ||
| const baseLine = `base_url = "${resolved.baseUrl}"`; | ||
| if (!providerSectionPattern.test(tomlContent)) return { env, configured: false }; |
There was a problem hiding this comment.
[/tdd] if (!providerSectionPattern.test(tomlContent)) return { env, configured: false }; is immediately followed by the now-dead if (providerSectionPattern.test(tomlContent)) { ... }, which is always true at that point. The redundant branch should be flattened — it's a correctness smell, not just style, since it obscures the actual early-return path this PR relies on to trigger the new isCodexAzureOIDC && (!codexHome || !providerConfig.configured) fatal guard.
💡 Suggested cleanup
if (codexConfigPath) {
const tomlContent = fs.readFileSync(codexConfigPath, "utf8");
const providerSectionPattern = /\[model_providers\.openai-proxy\][\s\S]*?(?=\n\[|$)/;
if (!providerSectionPattern.test(tomlContent)) return { env, configured: false };
const baseLine = `base_url = "${resolved.baseUrl}"`;
const rewritten = tomlContent.replace(providerSectionPattern, section => { ... });
fs.writeFileSync(codexConfigPath, rewritten, "utf8");
}The test suite does cover the "missing Codex proxy configuration" case (refuses to spawn when Codex proxy configuration is missing), which is good — but it tests behavior, not this specific dead-branch smell. Low severity, but worth a quick cleanup while the surrounding logic is fresh.
@copilot please address this.
There was a problem hiding this comment.
Flattened the provider-section rewrite after its early return; the redundant condition is removed. Fixed in ca2b637.
| } | ||
|
|
||
| // Entra token exchange is owned by the AWF sidecar, never by the Codex process. | ||
| func isCodexAzureOIDC(workflowData *WorkflowData) bool { |
There was a problem hiding this comment.
[/codebase-design] isCodexAzureOIDC accepts auth.Type == "github-oidc" && auth.Provider == "azure" with no check that AzureTenantID/AzureClientID are non-empty, unlike the existing GCP WIF path (validateGCPWIFEngineAuth in compiler_validators.go), which fails the compile with a clear error listing missing fields.
💡 Why this is inconsistent and risky
Without azure-tenant-id/azure-client-id, this predicate still returns true (static secrets suppressed, env_key omitted, GH_AW_CODEX_OIDC_AUTH=azure set), while AWF has no way to actually perform the token exchange — the workflow compiles successfully but fails at runtime with an opaque error, deep in the AWF sidecar or the harness's "unable to configure Codex for the Azure OIDC AWF proxy" guard, rather than at gh aw compile/gh aw validate time.
The codebase already has the right pattern for this (GCP WIF): a dedicated validate*WIFEngineAuth function registered in the validator table (compiler_validators.go:259) that fails fast with an actionable message, e.g. engine.auth with provider=gcp requires the following fields: ....
Suggested fix: add an analogous validateAzureWIFEngineAuth (or extend isCodexAzureOIDC's caller) that requires azure-tenant-id and azure-client-id when auth.type == github-oidc && auth.provider == azure, and register it in the same validator table. This keeps failure modes consistent across providers and catches misconfiguration before any AWF run.
@copilot please address this.
There was a problem hiding this comment.
Added compile-time Azure WIF validation requiring both azure-tenant-id and azure-client-id, alongside the existing GCP validation. Fixed in ca2b637.
|
@copilot address the following outstanding work in one pass:
Push the necessary fixes, reply to each listed review thread and resolve it when addressed. Ignore feedback already answered or resolved. Use the pr-finisher skill and stop when only human review or CI remains; do not trigger CI. Sous-chef head: eba38ce
|
…a-oidc Co-authored-by: gh-aw-bot <[email protected]>
|
@copilot refactor the Azure IDC functions and ensure the PI Agentic Engine supports them as well. Add Smoke Azure PI and Smoke Azure Codex workflows. |
Co-authored-by: gh-aw-bot <[email protected]>
Co-authored-by: pelikhan <[email protected]>
Implemented shared Azure OIDC handling for Pi, added fail-closed fresh |
|
@copilot address the following outstanding work in one pass:
Push the necessary fixes, reply to each listed review thread and resolve it when addressed. Ignore feedback already answered or resolved. Use the pr-finisher skill and stop when only human review or CI remains; do not trigger CI. Sous-chef head: da2b8c1
|
Co-authored-by: gh-aw-bot <[email protected]>
…a-oidc Co-authored-by: gh-aw-bot <[email protected]>
Co-authored-by: gh-aw-bot <[email protected]>
Merged latest |
|
@copilot do a security review of the compiled lock.yml, make sure secrets are properly configured |
Reviewed both compiled Azure smoke locks. Azure auth is keyless as intended: the agent jobs alone receive One conditional medium hardening concern: both locks place Strict source compilation passed. The dry-run scanner gate did not pass: it reported generated-lock lint issues and repo-wide runner-guard findings; Poutine and ShellCheck passed. No workflow was dispatched. |
|
🎉 This pull request is included in a new release. Release: |

Native Codex still required an API key when configured for Azure GitHub OIDC, despite AWF supporting Entra token exchange. This change enables keyless execution through the AWF proxy.
env_key, retaining Responses andrequires_openai_auth = false.github-oidc/azure. Refuse startup if reflection or proxy configuration is unavailable.Requires the AWF agent sandbox and an Entra federated credential matching the workflow’s GitHub OIDC issuer, subject, and audience.