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:
cooper-oai
2026-11-05 03:49:13 +00:00
committed by copyberry
parent c90354172c
commit 5c0b1ac71f
55 changed files with 2145 additions and 252 deletions
+29 -4
View File
@@ -33,6 +33,7 @@ use codex_login::test_support::auth_manager_from_optional_auth;
use codex_protocol::auth::AuthMode;
use codex_protocol::protocol::Product;
use codex_protocol::protocol::SkillScope;
use codex_runtime_agent_instance::RuntimeAuthSlot;
use codex_skills::LoadedSkillRoot;
use codex_skills::LoadedSkills;
use codex_skills::SkillError;
@@ -81,6 +82,7 @@ pub(crate) fn test_plugins_manager_with_options(
codex_home,
restriction_product,
test_auth_manager(auth_mode),
RuntimeAuthSlot::default(),
test_skill_root_loader(),
)
}
@@ -94,6 +96,7 @@ pub(crate) fn test_plugins_manager_with_auth_manager(
codex_home,
restriction_product,
auth_manager,
RuntimeAuthSlot::default(),
test_skill_root_loader(),
)
}
@@ -327,6 +330,13 @@ pub(crate) struct RecordingHttpClientSelector {
}
impl RecordingHttpClientSelector {
fn record_url(&self, url: &str) {
match self.selected_urls.lock() {
Ok(mut selected_urls) => selected_urls.push(url.to_string()),
Err(error) => panic!("selected URL recorder lock should not be poisoned: {error}"),
}
}
pub(crate) fn new() -> (Arc<Self>, Arc<Mutex<Vec<String>>>) {
let selected_urls = Arc::new(Mutex::new(Vec::new()));
let delegate = RouteAwareClientPool::with_chatgpt_cloudflare_cookies(
@@ -344,13 +354,27 @@ impl RecordingHttpClientSelector {
}
impl HttpClientSelector for RecordingHttpClientSelector {
fn for_current_account(&self) -> Arc<dyn HttpClientSelector> {
Arc::new(Self {
selected_urls: Arc::clone(&self.selected_urls),
delegate: self.delegate.for_current_account(),
})
}
fn request(&self, method: Method, url: &str) -> RequestBuilder {
match self.selected_urls.lock() {
Ok(mut selected_urls) => selected_urls.push(url.to_string()),
Err(error) => panic!("selected URL recorder lock should not be poisoned: {error}"),
}
self.record_url(url);
self.delegate.request(method, url)
}
fn request_for_account(
&self,
method: Method,
url: &str,
binding: &codex_http_client::NetworkPolicy,
) -> Option<RequestBuilder> {
self.record_url(url);
self.delegate.request_for_account(method, url, binding)
}
fn outbound_proxy_policy(&self) -> OutboundProxyPolicy {
self.delegate.outbound_proxy_policy()
}
@@ -362,6 +386,7 @@ pub(crate) fn recording_remote_plugin_service_config(
let (http_clients, selected_urls) = RecordingHttpClientSelector::new();
(
RemotePluginServiceConfig {
runtime_auth: None,
chatgpt_base_url,
product_sku: crate::remote::CODEX_PRODUCT_SKU.to_string(),
http_clients,