Skip to content

Support Azure Entra OIDC in the native Codex engine #68026

Done

Description

@SadriG91

A tested implementation is available on this branch:
https://github.com/SadriG91/gh-aw/tree/fix/codex-entra-oidc

Diff against the upstream base used for the implementation:
SadriG91/gh-aw@ff73e83...8bb818a

The changes are in commit 8bb818ad. GitHub declined creation of a community PR, so this proposal follows CONTRIBUTING.md's issue-based contribution process.

Problem

A Codex workflow with engine.auth: {type: github-oidc, provider: azure} still requires CODEX_API_KEY or OPENAI_API_KEY, even though the AWF OpenAI adapter already supports exchanging GitHub OIDC assertions for Entra access tokens. Both the generated secret-validation step and codex_harness.cjs reject keyless execution; the generated provider configuration also requires CODEX_API_KEY through env_key.

Change

Enable the existing native Codex engine to use the Entra-authenticated AWF proxy:

  • Suppress the primary OpenAI API-key requirement only when Azure GitHub OIDC and the AWF sandbox are enabled. Preserve MCP and other-provider credential requirements.
  • Omit env_key from the managed Codex proxy configuration; retain the Responses protocol and requires_openai_auth = false.
  • Emit a non-secret launch policy and require fresh AWF reflection to advertise a configured OpenAI endpoint with auth_type: github-oidc/azure before starting Codex. Refuse startup if reflection or the proxy configuration is unavailable.
  • Apply the same behavior to inherited Codex threat detection and same-provider fallback models.
  • Document Azure OpenAI and internal gateway configuration, including custom Entra scopes and federated-credential prerequisites.

Token exchange and refresh remain in the existing AWF sidecar. No Entra token is passed to Codex, no dummy API key is required, and Actions OIDC request credentials remain excluded from the agent sandbox. This introduces no Telia-specific endpoint or identity settings.

Implementation plan

The linked commit implements this plan and can be used as the starting point:

  1. In pkg/workflow/codex_engine.go, make GetRequiredSecretNames, GetSecretValidationStep and buildCodexExecutionEnv conditional on Azure OIDC with the AWF firewall enabled. Emit the non-secret GH_AW_CODEX_OIDC_AUTH=azure runtime policy.
  2. In pkg/workflow/codex_config.go, omit the managed proxy's env_key in that mode while preserving Responses and requires_openai_auth=false.
  3. In actions/setup/js/codex_harness.cjs, permit keyless startup only after fresh reflection confirms a configured OpenAI proxy using github-oidc/azure. Use that reflection to configure the proxy endpoint and refuse startup if its configuration is missing.
  4. In pkg/workflow/engine_fallback_models.go, preserve keyless authentication for same-provider OpenAI fallbacks without suppressing unrelated providers' credentials.
  5. Add compiler coverage in pkg/workflow/codex_azure_oidc_test.go and runtime coverage in actions/setup/js/codex_harness.test.cjs. Cover API-key compatibility, absent or mismatched proxy authentication, detector inheritance and fallback behavior.
  6. Update docs/src/content/docs/reference/auth.mdx and engines.md with configuration and federated-credential prerequisites. Run the existing pre-PR validation gate and a live Azure OIDC pilot before release.

Expected configuration

permissions:
  contents: read
  id-token: write
engine:
  id: codex
  model: gpt-5.4
  auth:
    type: github-oidc
    provider: azure
    azure-tenant-id: ${{ vars.AZURE_TENANT_ID }}
    azure-client-id: ${{ vars.AZURE_CLIENT_ID }}
    audience: api://AzureADTokenExchange
    azure-scope: ${{ vars.AI_GATEWAY_SCOPE }}
  env:
    OPENAI_BASE_URL: ${{ vars.AI_GATEWAY_BASE_URL }}
network:
  allowed:
    - defaults
    - gateway.example.com
    - login.microsoftonline.com

The Entra application already has a federated credential matching the workflow's GitHub OIDC issuer, subject and audience, and access to the target API. The custom scope supports an Entra-protected internal Responses gateway as well as Azure OpenAI's default scope. Keep the AWF agent sandbox enabled.

Validation

  • make build and make fmt passed.
  • make lint-cjs passed; existing warnings remain.
  • make agent-report-progress passed: change-scoped Go/JavaScript lint, typecheck, impacted tests, and all 337 workflows compiled with no lock-file drift.
  • go test ./pkg/workflow -run 'TestCodex|TestFallbackModels' -count=1 passed, including the new compiler, credential-isolation, detector-inheritance and fallback tests.
  • The Codex harness suite passed all 182 tests. A combined validation run initially hit an existing SIGTERM timing test (expected exit 1, received 143); the standalone rerun passed.
  • A loopback smoke test with real Codex CLI 0.162.1 reached /responses without an API key or Authorization header. The mock deliberately returned 401; this verifies client startup, not a live Entra exchange.

No live Azure/GitHub OIDC exchange has been performed for this patch.

Activity

  1. locked and limited conversation to collaborators on Oct 12, 2026
  2. unlocked this conversation on Oct 12, 2026
  3. linked a pull request that will close this issueSupport Azure Entra OIDC in native Codex #68457on Oct 13, 2026
  4. SadriG91 commented on Oct 13, 2026

    @SadriG91
    Author

    Thank you for the quick turnaround on this 👏

  5. locked and limited conversation to collaborators on Oct 13, 2026
  6. unlocked this conversation on Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions