Skip to content

Add OpenAI workload identity federation to the API proxy - #11364

Merged
lpcox merged 6 commits into
mainfrom
copilot/api-proxy-support-openai-wif
Nov 9, 2026
Merged

lpcox merged 6 commits into
mainfrom
copilot/api-proxy-support-openai-wif

Conversation

Copilot AI commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

The API proxy lacked OpenAI’s GitHub Actions OIDC exchange, preventing keyless OpenAI authentication. Add native WIF support while keeping exchanged tokens inside the sidecar.

  • Token exchange: Request a GitHub OIDC token for the configured audience, exchange it at auth.openai.com, and cache and refresh the returned access token before expiry.
  • Credential isolation: Route OpenAI WIF requests through the proxy with a placeholder key; send the exchanged token upstream as a bearer credential. Federation settings are excluded from the agent environment.
  • Egress: Automatically allow auth.openai.com through Squid only when OpenAI WIF is selected.
AWF_AUTH_TYPE=github-oidc
AWF_AUTH_PROVIDER=openai
AWF_AUTH_OPENAI_IDENTITY_PROVIDER_ID=...
AWF_AUTH_OPENAI_SERVICE_ACCOUNT_ID=...
# Optional; defaults to https://api.openai.com/v1
AWF_AUTH_OIDC_AUDIENCE=https://api.openai.com/v1

Comment thread src/api-proxy-config-domains.ts Resolved
Copilot AI changed the title [WIP] Add OpenAI workload identity federation support to API proxy Add OpenAI workload identity federation to the API proxy Nov 9, 2026
Copilot AI requested a review from lpcox November 9, 2026 14:55
@lpcox
lpcox marked this pull request as ready for review November 9, 2026 15:33
Copilot AI adaptive review requested due to automatic review settings November 9, 2026 15:33
lpcox and others added 2 commits November 9, 2026 07:33
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Documentation Preview

Documentation has been built for this PR.

Download preview artifact

To view locally:

  1. Download the docs-preview-pr-11364 artifact from the workflow run
  2. Unzip and open index.html in your browser

Built from commit 3fdb737

Comment thread src/api-proxy-config-domains.ts Fixed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The shared OIDC resolver can send live OpenAI WIF tokens to unrelated Anthropic and Copilot upstreams, breaking credential isolation and potentially overriding an Anthropic static key.

5 open issues
What changed in this PR

Adds native OpenAI workload identity federation to AWF’s API-proxy authentication pipeline, enabling keyless GitHub Actions authentication while keeping exchanged tokens inside the sidecar.

Changes:

  • Adds GitHub OIDC token exchange with cached, automatically refreshed OpenAI access tokens.
  • Enables keyless agent routing through placeholder credentials and isolates federation settings.
  • Adds authentication-host allowlist handling, documentation, tests, and container packaging.
File Description
src/​services/​credentials/​openai-oidc-config.ts Detects complete OpenAI WIF configuration.
src/​services/​credentials/​openai-credential-env.ts Enables proxy routing without a static key.
src/​services/​credentials/​openai-credential-env.test.ts Tests WIF routing and placeholder credentials.
src/​services/​api-proxy-env-config.test.ts Tests federation identifier forwarding.
src/​services/​agent-environment/​excluded-vars.ts Excludes federation identifiers from agent passthrough.
src/​services/​agent-environment/​excluded-vars.test.ts Tests the new environment exclusions.
src/​api-proxy-env-constants.ts Registers federation identifiers for sidecar forwarding.
src/​api-proxy-config-domains.ts Adds conditional authentication-host allowlisting.
src/​api-proxy-config-domains.test.ts Tests authentication-host allowlist conditions.
docs/​auth-matrix.md Documents native OpenAI WIF configuration and behavior.
containers/​api-proxy/​server.custom-auth-header.test.js Tests mandatory bearer authentication for native WIF.
containers/​api-proxy/​providers/​openai.js Selects bearer headers for native WIF tokens.
containers/​api-proxy/​providers/​cloud-oidc-init.test.js Tests OpenAI WIF provider initialization.
containers/​api-proxy/​providers/​cloud-oidc-init.js Adds native OpenAI token-provider construction.
containers/​api-proxy/​openai-oidc-token-provider.test.js Tests exchange payloads, caching, expiry, and errors.
containers/​api-proxy/​openai-oidc-token-provider.js Implements token exchange and refresh integration.
containers/​api-proxy/​Dockerfile Packages the new token-provider module.

Review effort: Max (auto)

Comment on lines +61 to +65
} else if (authProvider === 'openai') {
const identityProviderId = env.AWF_AUTH_OPENAI_IDENTITY_PROVIDER_ID;
const serviceAccountId = env.AWF_AUTH_OPENAI_SERVICE_ACCOUNT_ID;
if (identityProviderId && serviceAccountId) {
const { OpenAIOidcTokenProvider } = require('../openai-oidc-token-provider');
Comment thread src/api-proxy-config-domains.test.ts Outdated
Comment on lines +9 to +18
it('allows the OpenAI WIF token exchange host only for OpenAI OIDC auth', () => {
const domains: string[] = [];

resolveApiTargetsToAllowedDomains({}, domains, {
AWF_AUTH_TYPE: 'github-oidc',
AWF_AUTH_PROVIDER: 'openai',
});

expect(domains).toContain('auth.openai.com');
});
const providerType = (env[COPILOT_ENV.PROVIDER_TYPE] || '').trim().toLowerCase();
const authType = (env.AWF_AUTH_TYPE || '').trim().toLowerCase();
const authProvider = (env.AWF_AUTH_PROVIDER || 'azure').trim().toLowerCase();
const openAiWifRequested = authType === 'github-oidc' && authProvider === 'openai';
},
createHeaderBuilders: ({ apiKey }) => ({
buildOidcHeaders: buildTokenAuthHeaders,
buildOidcHeaders: openAiWifRequested ? bearerAuthHeaders : buildTokenAuthHeaders,
Comment thread src/api-proxy-config-domains.ts Outdated
Boolean(env['AWF_AUTH_OPENAI_SERVICE_ACCOUNT_ID']?.trim()) &&
!allowedDomains.includes('auth.openai.com')
) {
allowedDomains.push('auth.openai.com');
@lpcox

lpcox commented Nov 9, 2026

Copy link
Copy Markdown
Collaborator

@copilot address review feedback

Copilot AI commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

@copilot address review feedback

Addressed the OpenAI WIF review feedback in dd339cc: native WIF is limited to the OpenAI adapter, model discovery uses resolved bearer auth once ready, incomplete configuration reports the required settings, and the auth host is no longer added to the agent allowlist.

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

✅ Copilot review passed with no inline comments.

@copilot Add the ready-for-aw label to this PR to trigger agentic CI smoke tests.

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

✅ Coverage Check Passed

Overall Coverage

Metric Base PR Delta
Lines 93.80% 93.83% 📈 +0.03%
Statements 92.35% 92.37% 📈 +0.02%
Functions 93.02% 93.06% 📈 +0.04%
Branches 86.69% 86.74% 📈 +0.05%
📁 Per-file Coverage Changes (4 files)
File Lines (Before → After) Statements (Before → After)
src/services/api-proxy-service-config.ts 100.0% → 97.6% (-2.44%) 100.0% → 97.6% (-2.39%)
src/config-file.ts 100.0% → 97.6% (-2.39%) 100.0% → 97.8% (-2.23%)
src/services/api-proxy-env-config.ts 99.0% → 99.1% (+0.04%) 99.1% → 98.3% (-0.80%)
src/nvx/one-shot-process.ts 81.5% → 84.0% (+2.47%) 74.7% → 76.8% (+2.11%)
✨ New Files (2 files)
  • src/trusted-service.ts: 98.6% lines
  • src/services/credentials/openai-oidc-config.ts: 100.0% lines

Coverage comparison generated by scripts/ci/compare-coverage.ts

@lpcox
lpcox merged commit 3fb6aff into main Nov 9, 2026
45 of 47 checks passed
@lpcox
lpcox deleted the copilot/api-proxy-support-openai-wif branch November 9, 2026 17: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.

API proxy: support OpenAI workload identity federation (AWF_AUTH_OPENAI_*)

4 participants