Repository navigation
Add OpenAI workload identity federation to the API proxy - #11364
Conversation
Co-authored-by: lpcox <[email protected]>
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>
Documentation PreviewDocumentation has been built for this PR. To view locally:
Built from commit 3fdb737 |
There was a problem hiding this comment.
🟡 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
Prevent OpenAI WIF credentials from leaking to other adapters · New Replace incomplete WIF fixture with a configured allowlist test · New Report missing OIDC configuration for OpenAI WIF · New Enable model discovery after native OpenAI WIF token acquisition · New Remove auth-host auto-add from the agent allowlist · New
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)
| } 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'); |
| 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, |
| Boolean(env['AWF_AUTH_OPENAI_SERVICE_ACCOUNT_ID']?.trim()) && | ||
| !allowedDomains.includes('auth.openai.com') | ||
| ) { | ||
| allowedDomains.push('auth.openai.com'); |
|
@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. |
|
✅ Copilot review passed with no inline comments. @copilot Add the |
✅ Coverage Check PassedOverall Coverage
📁 Per-file Coverage Changes (4 files)
✨ New Files (2 files)
Coverage comparison generated by |


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.
auth.openai.com, and cache and refresh the returned access token before expiry.auth.openai.comthrough 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