mirror of
https://github.com/openai/codex.git
synced 2026-11-29 00:00:54 +00:00
Share runtime authentication with model providers and catalogs (#57607)
## Why Model catalog refreshes need to use the same registered actor and credential owner as model requests when runtime authentication is enabled. ## What changed - Add `ProviderAuthContext` to carry credentials and optional runtime authentication into model providers and catalog clients. - Select runtime authentication independently for inference and catalog destinations. Reject unsupported OpenAI origins while preserving provider authentication for other destinations. - Include API organization and project selectors in runtime registration. Reuse registered runtimes across projects within an organization and replace them when the organization changes. - Preserve transport restrictions and account bindings, and strip sensitive headers on cross-origin redirects. - Apply the catalog timeout to authentication and fetching while allowing credential refresh and registration to finish safely. ## Testing Add coverage for runtime-authenticated catalogs, provider isolation, resource selection, gateway authentication, cross-origin redirects, and timeout recovery that preserves registration and refreshed tokens. GitOrigin-RevId: c14f1a02159031ea0af1f9b26ea890f8dca7d6ad
This commit is contained in:
@@ -167,6 +167,7 @@ impl fmt::Debug for OutboundProxyRoute {
|
||||
pub struct HttpClientFactory {
|
||||
outbound_proxy_policy: OutboundProxyPolicy,
|
||||
system_proxy_fallback: bool,
|
||||
protect_sensitive_headers: bool,
|
||||
chatgpt_cookie_store: Option<Arc<ChatGptCookieStore>>,
|
||||
network_policy: NetworkPolicy,
|
||||
}
|
||||
@@ -175,6 +176,7 @@ impl PartialEq for HttpClientFactory {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.outbound_proxy_policy == other.outbound_proxy_policy
|
||||
&& self.system_proxy_fallback == other.system_proxy_fallback
|
||||
&& self.protect_sensitive_headers == other.protect_sensitive_headers
|
||||
&& self.network_policy == other.network_policy
|
||||
&& self
|
||||
.chatgpt_cookie_store
|
||||
@@ -194,6 +196,7 @@ impl fmt::Debug for HttpClientFactory {
|
||||
f.debug_struct("HttpClientFactory")
|
||||
.field("outbound_proxy_policy", &self.outbound_proxy_policy)
|
||||
.field("system_proxy_fallback", &self.system_proxy_fallback)
|
||||
.field("protect_sensitive_headers", &self.protect_sensitive_headers)
|
||||
.field("network_policy", &self.network_policy)
|
||||
.finish()
|
||||
}
|
||||
@@ -205,11 +208,24 @@ impl HttpClientFactory {
|
||||
Self {
|
||||
outbound_proxy_policy,
|
||||
system_proxy_fallback: false,
|
||||
protect_sensitive_headers: false,
|
||||
chatgpt_cookie_store: None,
|
||||
network_policy: NetworkPolicy::unmanaged(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Follows redirects while keeping headers marked sensitive on the original origin.
|
||||
/// Reqwest's default redirect handling only recognizes standard credential headers.
|
||||
pub fn with_sensitive_header_protection(mut self) -> Self {
|
||||
self.protect_sensitive_headers = true;
|
||||
self
|
||||
}
|
||||
|
||||
/// Whether redirect handling removes sensitive headers when the origin changes.
|
||||
pub fn protects_sensitive_headers(&self) -> bool {
|
||||
self.protect_sensitive_headers
|
||||
}
|
||||
|
||||
/// Carries the account/configuration owner's application policy into every transport.
|
||||
pub fn with_network_policy(mut self, policy: NetworkPolicy) -> Self {
|
||||
self.network_policy = policy;
|
||||
|
||||
Reference in New Issue
Block a user