Skip to content

Extract OIDC/auth helpers from proxy-utils into oidc-adapter-utils#5604

Merged
lpcox merged 3 commits into
mainfrom
copilot/refactor-oidc-adapter-utils
Jun 27, 2026
Merged

Extract OIDC/auth helpers from proxy-utils into oidc-adapter-utils#5604
lpcox merged 3 commits into
mainfrom
copilot/refactor-oidc-adapter-utils

Conversation

Copilot AI commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

containers/api-proxy/proxy-utils.js had grown past its stated role as a pure/shared proxy helper module by also carrying OIDC runtime wiring and auth-header validation. This change separates the security-sensitive OIDC/auth path into its own module so auth logic can be reviewed independently of URL, header, and body utility code.

  • Extract OIDC/auth helpers into a dedicated module

    • Added containers/api-proxy/oidc-adapter-utils.js
    • Moved:
      • isValidHeaderName
      • validateAuthHeaderEnv
      • createOidcRuntimeAdapterMethods
      • resolveOidcAuthHeaders
  • Narrow proxy-utils.js back to general proxy helpers

    • Kept URL normalization, upstream path building, header stripping, body transform composition, and unconfigured-response helpers in proxy-utils.js
    • Removed OIDC/auth exports from that module
  • Split callers along the new boundary

    • Updated provider/auth code to import OIDC/auth helpers from oidc-adapter-utils.js
    • Left non-auth callers on proxy-utils.js
    • This aligns the import graph with the actual responsibility split instead of mixing credential-path code with general request utilities
  • Preserve container packaging for the new runtime module

    • Added oidc-adapter-utils.js to the api-proxy Dockerfile COPY list so the extracted module is present in the runtime image
  • Keep the module boundary explicit in tests

    • Updated the focused OIDC helper test to import from oidc-adapter-utils.js
    • Added direct coverage for auth-header validation helpers in the new module

Example of the new import split:

const {
  normalizeBasePath,
  parseApiTargetAndBasePath,
} = require('../proxy-utils');

const {
  validateAuthHeaderEnv,
  resolveOidcAuthHeaders,
} = require('../oidc-adapter-utils');

Copilot AI changed the title [WIP] Refactor to extract OIDC/auth utilities into oidc-adapter-utils.js Extract OIDC/auth helpers from proxy-utils into oidc-adapter-utils Jun 27, 2026
Copilot finished work on behalf of lpcox June 27, 2026 15:43
Copilot AI requested a review from lpcox June 27, 2026 15:43
@lpcox lpcox marked this pull request as ready for review June 27, 2026 15:46
Copilot AI review requested due to automatic review settings June 27, 2026 15:46

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.

Pull request overview

This PR refactors the api-proxy’s auth/OIDC-related helpers out of containers/api-proxy/proxy-utils.js into a dedicated containers/api-proxy/oidc-adapter-utils.js module, keeping security-sensitive OIDC/auth-header logic separated from general proxy utilities and ensuring the runtime image includes the new module.

Changes:

  • Extracted OIDC/auth helper functions into oidc-adapter-utils.js and removed their exports from proxy-utils.js.
  • Updated provider/adaptor callers and the focused OIDC tests to import helpers from the new module.
  • Updated the api-proxy Dockerfile COPY list to include the new runtime module.
Show a summary per file
File Description
containers/api-proxy/oidc-adapter-utils.js New module containing extracted OIDC/auth-header validation and runtime adapter helpers.
containers/api-proxy/proxy-utils.js Removes OIDC/auth helpers to narrow this file back to general proxy utilities.
containers/api-proxy/proxy-utils.oidc.test.js Updates tests to target the new oidc-adapter-utils module and adds coverage for header validation helpers.
containers/api-proxy/providers/openai.js Imports validateAuthHeaderEnv from oidc-adapter-utils instead of proxy-utils.
containers/api-proxy/providers/anthropic.js Imports auth/OIDC helpers from oidc-adapter-utils, leaving proxy helpers on proxy-utils.
containers/api-proxy/providers/copilot.js Imports resolveOidcAuthHeaders from oidc-adapter-utils.
containers/api-proxy/providers/copilot-byok.js Imports isValidHeaderName from oidc-adapter-utils.
containers/api-proxy/providers/cloud-oidc-init.js Imports OIDC runtime helper functions from oidc-adapter-utils.
containers/api-proxy/Dockerfile Copies oidc-adapter-utils.js into the runtime image to prevent MODULE_NOT_FOUND at runtime.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 9/9 changed files
  • Comments generated: 1
  • Review effort level: Low

Comment thread containers/api-proxy/proxy-utils.oidc.test.js
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@github-actions

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 Jun 27, 2026

Copy link
Copy Markdown
Contributor

✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟

@github-actions

github-actions Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Smoke Gemini completed. All facets verified. 💎

@github-actions

github-actions Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Contribution Check completed successfully!

Contribution check complete for PR #5604: the PR follows applicable CONTRIBUTING.md guidelines; no comment needed.

@github-actions

github-actions Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Smoke Copilot BYOK AOAI (api-key) completed. Copilot AOAI BYOK (api-key) mode operational. 🔓

@github-actions

github-actions Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Smoke Copilot BYOK completed. Copilot BYOK mode operational. 🔓

@github-actions

github-actions Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤

@github-actions

github-actions Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Security Guard failed. Please review the logs for details.

@github-actions

github-actions Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

🔑 Smoke Copilot PAT PAT auth validated. All systems operational. ✅

@github-actions

github-actions Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

📡 Smoke OTel Tracing completed. All tracing scenarios validated. ✅

@github-actions

github-actions Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Chroot tests passed! Smoke Chroot - All security and functionality tests succeeded.

@github-actions

github-actions Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Smoke Copilot BYOK AOAI (Entra) completed. Copilot AOAI BYOK (Entra) mode operational. 🔓

@github-actions

github-actions Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

🔌 Smoke Services — All services reachable! ✅

@github-actions

github-actions Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Build Test Suite completed successfully!

@github-actions

github-actions Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Smoke Claude passed

@github-actions

Copy link
Copy Markdown
Contributor

✅ Coverage Check Passed

Overall Coverage

Metric Base PR Delta
Lines 98.24% 98.28% 📈 +0.04%
Statements 98.17% 98.21% 📈 +0.04%
Functions 99.53% 99.53% ➡️ +0.00%
Branches 94.00% 94.00% ➡️ +0.00%
📁 Per-file Coverage Changes (1 files)
File Lines (Before → After) Statements (Before → After)
src/workdir-setup.ts 92.7% → 94.5% (+1.82%) 92.7% → 94.5% (+1.82%)

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

@github-actions github-actions Bot mentioned this pull request Jun 27, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: Claude Engine Validation

  • API check: ✅ PASS
  • gh CLI check: ✅ PASS
  • File check: ✅ PASS

Overall result: PASS

Generated by Smoke Claude for issue #5604 · 37.2 AIC · ⊞ 3.3K ·

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: Copilot PAT Auth — FAIL

Test Result
GitHub MCP connectivity ✅ (PR #5587: "fix(test): sync doc-maintainer test with max-turns 15 + prompt rewrite")
GitHub.com HTTP connectivity ❌ (pre-step data not available — template vars unsubstituted)
File write/read ❌ (pre-step data not available — template vars unsubstituted)

Overall: FAIL — pre-step outputs missing; HTTP and file tests could not be verified.

Auth mode: PAT (COPILOT_GITHUB_TOKEN) | PR author: @Copilot | Assignees: @lpcox, @Copilot

🔑 PAT report filed by Smoke Copilot PAT

@github-actions

Copy link
Copy Markdown
Contributor

🔑 Smoke Test: Copilot BYOK (Direct Mode)

GitHub MCP Connectivity — Verified 2 merged PRs via MCP
GitHub.com HTTP — HTTP 200 response
File Write/Read — Smoke test file created and retrieved
BYOK Inference — Agent responding (api-proxy sidecar active)

Status: PASS — Running in direct BYOK mode (COPILOT_PROVIDER_API_KEY) via api-proxy → api.githubcopilot.com

Attribution: @lpcox

🔑 BYOK report filed by Smoke Copilot BYOK

@github-actions

Copy link
Copy Markdown
Contributor

🤖 Smoke Test Results — PASS

PR: Extract OIDC/auth helpers from proxy-utils into oidc-adapter-utils
Author: @Copilot | Assignees: @lpcox @Copilot

Test Result
GitHub MCP connectivity
github.com HTTP (200)
File write/read

Overall: ✅ PASS

📰 BREAKING: Report filed by Smoke Copilot

@github-actions

Copy link
Copy Markdown
Contributor

Smoke test summary:

  • fix(test): sync doc-maintainer test with max-turns 15 + prompt rewrite ✅
  • refactor: split host-iptables-setup.test.ts into focused test modules ✅
  • GitHub title check ✅
  • Playwright title check ✅
  • File write check ✅
  • Discussion check ✅
  • Build check ✅
    Overall: PASS

🔮 The oracle has spoken through Smoke Codex

@github-actions

Copy link
Copy Markdown
Contributor

Gemini Smoke Test Results

  • GitHub MCP Testing: ❌ (Tools not found/accessible)
  • GitHub.com Connectivity: ❌ (Status 000, SSL Error 35)
  • File Writing Testing: ✅
  • Bash Tool Testing: ✅

Overall status: FAIL

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • localhost

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "localhost"

See Network Configuration for more information.

💎 Faceted by Smoke Gemini

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: API Proxy OpenTelemetry Tracing

Scenario Result Detail
Module Loading otel.js loads; exports startRequestSpan, setTokenAttributes, setBudgetAttributes, endSpan, isEnabled, shutdown + 7 internals
Test Suite 59 passed, 0 failed (2 suites: otel.test.js + split-module tests)
Env Var Forwarding api-proxy-env-config.ts forwards GH_AW_OTLP_ENDPOINTS, OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_HEADERS, GITHUB_AW_OTEL_TRACE_ID, GITHUB_AW_OTEL_PARENT_SPAN_ID, OTEL_SERVICE_NAME
Token Tracker Integration onUsage callback present in token-tracker-http.js (L283/324) as OTEL hook point
OTEL Diagnostics / Graceful Degradation FileSpanExporter active when no OTLP endpoint set; spans fall back to /var/log/api-proxy/otel.jsonl; isEnabled() always returns true

All 5 scenarios pass. ✅

📡 OTel tracing validated by Smoke OTel Tracing

@github-actions

Copy link
Copy Markdown
Contributor

🧪 Chroot Version Comparison Results

Runtime Host Version Chroot Version Match?
Python Python 3.12.13 Python 3.12.3
Node.js v24.17.0 v22.23.0
Go go1.22.12 go1.22.12

Overall: ❌ Not all tests passed — Python and Node.js versions differ between host and chroot environments.

Tested by Smoke Chroot

@github-actions

Copy link
Copy Markdown
Contributor

🏗️ Build Test Suite Results

Ecosystem Project Build/Install Tests Status
Bun elysia 1/1 passed ✅ PASS
Bun hono 1/1 passed ✅ PASS
C++ fmt N/A ✅ PASS
C++ json N/A ✅ PASS
Deno oak N/A 1/1 passed ✅ PASS
Deno std N/A 1/1 passed ✅ PASS
.NET hello-world N/A ✅ PASS
.NET json-parse N/A ✅ PASS
Go color passed ✅ PASS
Go env passed ✅ PASS
Go uuid passed ✅ PASS
Java gson 1/1 passed ✅ PASS
Java caffeine 1/1 passed ✅ PASS
Node.js clsx All passed ✅ PASS
Node.js execa All passed ✅ PASS
Node.js p-limit All passed ✅ PASS
Rust fd 1/1 passed ✅ PASS
Rust zoxide 1/1 passed ✅ PASS

Overall: 8/8 ecosystems passed — ✅ PASS

Generated by Build Test Suite for issue #5604 · 34.3 AIC · ⊞ 7.8K ·

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: GitHub Actions Services Connectivity

Check Result
Redis PING ❌ timeout (port 6379 blocked by AWF iptables)
PostgreSQL pg_isready ❌ no response (port 5432 blocked by AWF iptables)
PostgreSQL SELECT 1 ❌ blocked

Overall: FAIL

AWF agent is running at 172.30.0.20; host.docker.internal172.17.0.1. AWF's iptables rules block Redis and database ports by design.

🔌 Service connectivity validated by Smoke Services

@github-actions

Copy link
Copy Markdown
Contributor

🪪 BYOK (AOAI Entra) report filed by Smoke Copilot BYOK AOAI (Entra)

@github-actions

Copy link
Copy Markdown
Contributor

@Copilot @lpcox
Apply safe dependency updates for June 2026 security refresh
Update transitive linkify-it to 5.0.1 in lockfile

✅ MCP tool connectivity
✅ GitHub.com HTTP
✅ File I/O
✅ Direct BYOK inference

Running in direct BYOK mode (COPILOT_PROVIDER_API_KEY + COPILOT_PROVIDER_BASE_URL) via api-proxy → Azure OpenAI (Foundry, o4-mini-aw)

Overall: PASS

🔑 BYOK (AOAI api-key) report filed by Smoke Copilot BYOK AOAI (api-key)

@lpcox lpcox merged commit 1796f27 into main Jun 27, 2026
85 of 88 checks passed
@lpcox lpcox deleted the copilot/refactor-oidc-adapter-utils branch June 27, 2026 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants