mirror of
https://github.com/openai/codex.git
synced 2026-10-31 19:28:49 +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:
@@ -63,6 +63,28 @@ impl RuntimeAuth {
|
||||
self.change_state
|
||||
}
|
||||
|
||||
/// Preserve the caller's transport settings and restrictions while binding requests to
|
||||
/// this credential's account. Independent managed policies must not replace each other.
|
||||
pub fn bind_http_client_factory(
|
||||
&self,
|
||||
factory: HttpClientFactory,
|
||||
) -> Result<HttpClientFactory, AuthError> {
|
||||
let account_policy = self.http_client_factory().network_policy();
|
||||
let policy = factory
|
||||
.network_policy()
|
||||
.clone()
|
||||
.with_account_binding(account_policy)
|
||||
.ok_or_else(|| {
|
||||
AuthError::Build(
|
||||
"runtime credentials and transport must share the application network policy"
|
||||
.to_string(),
|
||||
)
|
||||
})?;
|
||||
Ok(factory
|
||||
.with_network_policy(policy)
|
||||
.with_sensitive_header_protection())
|
||||
}
|
||||
|
||||
/// Use this selection for a request and its retries; select auth again for the next request.
|
||||
pub fn into_auth_provider(self, mode: RuntimeAuthMode) -> codex_api::SharedAuthProvider {
|
||||
Arc::new(RuntimeRequestAuth { auth: self, mode })
|
||||
@@ -146,6 +168,7 @@ impl From<RuntimeAuthError> for AuthError {
|
||||
}
|
||||
RuntimeAuthError::Unavailable
|
||||
| RuntimeAuthError::Unsupported
|
||||
| RuntimeAuthError::UnsupportedResourceSelection
|
||||
| RuntimeAuthError::Changed
|
||||
| RuntimeAuthError::RefreshFailed
|
||||
| RuntimeAuthError::KeyGeneration
|
||||
|
||||
Reference in New Issue
Block a user