mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
## 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
33 lines
868 B
Rust
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()
|
|
}
|
|
}
|