Enforce workspace restrictions for header authentication (#39322)

## What changed

- Validate externally supplied header credentials against configured ChatGPT workspace restrictions using their `chatgpt-account-id` header.
- Reject header credentials with a missing or disallowed account ID, including credentials returned during refresh, without replacing the previously cached authentication.
- Document that identity headers must be bound to validated credentials because Codex uses them for managed authentication policy.

## Testing

- Add coverage for allowed, disallowed, and missing account IDs.
- Add coverage for rejecting a refresh that changes to a disallowed workspace.

GitOrigin-RevId: 3e3db2607cd8f9f1b8000472342e42e4b1cf00b2
This commit is contained in:
cooper-oai authored and copyberry committed 2026-08-19 00:28:52 +00:00
1 parent f1087ff151
commit b537d5a097
3 files changed
+80 -8

No files matched your search

+2
View File
@@ -6,6 +6,8 @@ use http::HeaderMap;
///
/// The provider owns credential validation, rotation, and persistence. Codex
/// keeps the resolved headers in memory and attaches them to backend requests.
/// Identity headers must be derived from and bound to the validated credentials;
/// Codex may use them to enforce managed authentication policy.
#[derive(Clone, PartialEq, Eq)]
pub struct AuthHeaders {
headers: HeaderMap,