Files
codex/codex-rs/login/src/auth/auth_headers.rs
T
cooper-oai b537d5a097 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
2026-08-19 00:28:52 +00:00

33 lines
868 B
Rust

use std::fmt;
use http::HeaderMap;
/// Request headers returned by an external auth provider.
///
/// 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,
}
impl AuthHeaders {
pub fn new(headers: HeaderMap) -> Self {
Self { headers }
}
pub fn headers(&self) -> &HeaderMap {
&self.headers
}
}
impl fmt::Debug for AuthHeaders {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("AuthHeaders")
.field("headers", &"<redacted>")
.finish()
}
}