Commit Graph
1 Commits
Author SHA1 Message Date
ad62166ba3 fix(copilot): preserve native inline OAuth identity (#4144)
## Description

Closes #3352.

Preserve the native inline editor OAuth identity without widening
Chat/Responses auth. Current head
`4609ac6b6162e81e4471492cb4c056065ce7f450` includes upstream main
`f1bc2609`.

## Type of Change

- [x] Bug fix
- [x] Documentation update
- [x] Code refactoring

## Changes Made

- Share one case-insensitive in-place header-removal helper across all
three auth branches; remove every unrelated provider API-key spelling
and every replaced Authorization spelling.
- Classify `ghu_` as the safe `ghu_***` kind and log that kind in the
inline branch, never the editor credential.
- Preserve the fetched same-origin/segment-boundary gateway-prefix fix
and its host/scheme/port regressions; this was already present in
`c368f1d`, not reimplemented here.
- Retain managed-seed exclusion and the existing Chat/Responses token
policy. No new live-account fallback or provider mock was introduced.
- Keep the optional path-helper extraction out; the small existing
origin guard remains explicit.

## Testing

- [x] Relevant unit/API regressions pass
- [x] Changed-file Ruff check and format pass
- [x] Manual auth operation/privacy smoke performed

### Test Output

```text
222 passed
181 passed, 5 warnings
ci-precheck PASSED — safe to push.
```

Focused command: `pytest -q tests/test_copilot_inline_client_auth.py
tests/test_copilot_auth.py tests/test_proxy_copilot_auth_hooks.py
tests/test_copilot_vscode_completions_routing.py
tests/test_copilot_integration_id_hmac.py`. Normal commit and full
pre-push hooks passed, including workspace Rust gates, genuine native
rebuild/import, critical Python and commitlint. No hooks/tests were
bypassed or filtered.

The first normal push hit the unchanged native
`expired_get_does_not_wipe_concurrent_refresh` final-live assertion: its
20 ms idle TTL can expire legitimately before the assertion under
scheduling load. This is the already-documented main stress-test issue,
not an auth-source change. A subsequent complete normal gate run used
`RUST_TEST_THREADS=1` and passed; no Rust fix or general flake
elimination is claimed.

## Real Behavior Proof

- Environment: Linux x86_64, Python 3.13.14, current published source,
real `apply_copilot_api_auth` and logging, synthetic credential
environment, isolated HOME, `DO_NOT_TRACK=1`.
- Exact command / steps: Execute `python
artifacts/review-20261013/run-native.py WORKTREE
TARGET/release/lib_core.so PROBE OUTPUT.json`. Invoke actual auth
operations for native inline on a different origin, same-origin prefixed
gateway inline, client-owned Chat gho, and Chat ghu requiring operator
replacement; include mixed-case duplicate API-key headers and capture
actual module logs.
- Observed result: Four auth cases preserve/select the correct identity,
remove all unrelated provider secrets, and log only safe kinds. Captured
kinds are `ghu_***`, `ghu_***`, `gho_***`, `ghu_***`; the full editor
credential and its suffix are absent. Existing real-proxy MockTransport
credential-gate and streaming/disconnect regressions passed in the
focused suite.
- Not tested: Live Copilot or VS Code signed-in end-to-end. The isolated
verification environment has no live Copilot credential; #3352 has no
reporter confirmation of this branch. The synthetic upstream/credential
gate is not presented as live entitlement proof. Full standalone mypy
and hosted-CI success are not asserted.

## Runtime Rollout Safety

- Rollout-managed feature(s): Existing Copilot auth routes; no feature
rollout added.
- Minimum rollout channel: Unchanged stable/default auth.
- Stable/default behavior changed: Inline token-kind diagnostics and one
shared secret-removal rule; native inline identity exception remains
host/path constrained.
- Kill switch / disable path: Existing Copilot upstream/auth
configuration; no new switch.
- Unsafe override required: No.
- Qualification impact: Auth selection, case-variant secret removal, log
privacy, gateway origin boundaries and existing proxy streaming gates
requalified; live entitlement remains external.
- Rollback path: Revert this auth helper/logging revision; no data
migration.

## Review Readiness

- [x] I have performed a self-review
- [x] This PR is ready for human review

## Checklist

- [x] Documentation updated
- [x] Did not edit `CHANGELOG.md`

---------

Co-authored-by: Tejas Chopra <tejas@headroomlabs.ai>
Co-authored-by: JerrettDavis <mxjerrett@gmail.com>
2026-10-24 08:38:54 -07:00