mirror of
https://github.com/openai/codex.git
synced 2026-11-18 22:20:48 +00:00
Extend runtime auth to account, plugin, and file requests (#59564)
## What changed - Use the shared runtime and effective configuration for account API clients and remote plugin requests, including standalone plugin commands. - Support dual-header and assertion-only authentication for remote plugins and MCP file uploads when runtime agent instances are enabled. - Keep plugin credentials and caches scoped to the thread's account when resuming with different credentials. Bind request pools and multi-step plugin storage operations to the selected account so account replacement revokes stale operations. - Protect runtime credentials on cross-origin redirects while preserving configured routing policies and legacy authentication for custom backends. - Apply server-provided `upload_headers` to file storage uploads. ## Testing Add coverage for shared runtime registration, both authentication modes, configuration reloads, resumed-thread account selection, account replacement during plugin uploads and downloads, and credential stripping on redirects. Extend file upload tests to verify runtime assertions and storage-only upload headers. GitOrigin-RevId: 68aef81051a6f9bf919fffda52f372b108fce805
This commit is contained in:
@@ -13,6 +13,7 @@ use codex_api::SharedAuthProvider;
|
||||
use codex_features::RuntimeAuthMode;
|
||||
use codex_http_client::CHATGPT_ACCOUNT_ID_HEADER;
|
||||
use codex_http_client::HttpClientFactory;
|
||||
use codex_http_client::RouteAwareClientPool;
|
||||
use codex_login::AuthHeaders;
|
||||
use codex_login::AuthManager;
|
||||
use codex_login::CodexAuth;
|
||||
@@ -112,6 +113,24 @@ impl ResolvedProviderAuth {
|
||||
}
|
||||
}
|
||||
|
||||
/// Preserve the caller's connection pool and bind it to the selected login.
|
||||
pub fn bind_http_client_pool(
|
||||
&self,
|
||||
pool: &RouteAwareClientPool,
|
||||
) -> Result<RouteAwareClientPool, AuthError> {
|
||||
match &self.runtime {
|
||||
Some(runtime) => pool
|
||||
.with_account_binding(runtime.http_client_factory().network_policy())
|
||||
.ok_or_else(|| {
|
||||
AuthError::Build(
|
||||
"runtime credentials and transport must share the application network policy"
|
||||
.to_string(),
|
||||
)
|
||||
}),
|
||||
None => Ok(pool.clone()),
|
||||
}
|
||||
}
|
||||
|
||||
/// Reject account selectors that disagree with the selected runtime.
|
||||
pub fn validate_headers(&self, headers: &HeaderMap) -> codex_protocol::error::Result<()> {
|
||||
if let Some(runtime) = &self.runtime {
|
||||
|
||||
Reference in New Issue
Block a user