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
@@ -136,6 +136,7 @@ pub(crate) async fn sync_remote_installed_plugin_bundles_once_with_snapshot(
previous_plugin_ids: &[PluginId],
) -> Result<RemoteInstalledPluginBundleSyncResult, RemoteInstalledPluginBundleSyncError> {
let auth = ensure_chatgpt_auth(auth)?;
let config = &config.for_current_account();
let authenticated_account_id = auth.get_account_id();
let fetched_installed_plugins = fetch_installed_plugins(
config,
+1 -5
View File
@@ -60,11 +60,7 @@ pub async fn search_remote_plugins(
}
let url = url.to_string();
let request = authenticated_request(
config.http_request(Method::GET, &url),
auth,
&config.product_sku,
)?;
let request = authenticated_request(config, Method::GET, &url, auth).await?;
let response: RemotePluginListResponse = send_and_decode(request, &url_for_error)
.await
.map_err(|error| match error {
+20 -36
View File
@@ -149,6 +149,7 @@ pub async fn save_remote_plugin_share(
access_policy: RemotePluginShareAccessPolicy,
) -> Result<RemotePluginShareSaveResult, RemotePluginCatalogError> {
let auth = ensure_chatgpt_auth(auth)?;
let config = &config.for_current_account();
let plugin_path_for_archive = plugin_path.as_path().to_path_buf();
let (filename, archive_bytes) = tokio::task::spawn_blocking(move || {
let filename = archive_filename(&plugin_path_for_archive)?;
@@ -285,11 +286,7 @@ pub async fn delete_remote_plugin_share(
let auth = ensure_chatgpt_auth(auth)?;
let base_url = config.chatgpt_base_url.trim_end_matches('/');
let url = format!("{base_url}/public/plugins/workspace/{remote_plugin_id}");
let request = authenticated_request(
config.http_request(Method::DELETE, &url),
auth,
&config.product_sku,
)?;
let request = authenticated_request(config, Method::DELETE, &url, auth).await?;
send_and_expect_status(request, &url, &[StatusCode::NO_CONTENT]).await?;
if let Err(err) = local_paths::remove_plugin_share_local_path(codex_home, remote_plugin_id) {
warn!(
@@ -322,15 +319,12 @@ pub async fn update_remote_plugin_share_targets(
.unwrap_or_default();
let base_url = config.chatgpt_base_url.trim_end_matches('/');
let url = format!("{base_url}/ps/plugins/{remote_plugin_id}/shares");
let request = authenticated_request(
config.http_request(Method::PUT, &url),
auth,
&config.product_sku,
)?
.json(&RemotePluginShareUpdateTargetsRequest {
discoverability,
targets,
});
let request = authenticated_request(config, Method::PUT, &url, auth)
.await?
.json(&RemotePluginShareUpdateTargetsRequest {
discoverability,
targets,
});
let response: RemotePluginShareUpdateTargetsResponse = send_and_decode(request, &url).await?;
Ok(RemotePluginShareUpdateTargetsResult {
principals: response.principals,
@@ -397,11 +391,7 @@ async fn get_created_workspace_plugins_page(
url.query_pairs_mut().append_pair("pageToken", page_token);
}
let url = url.to_string();
let request = authenticated_request(
config.http_request(Method::GET, &url),
auth,
&config.product_sku,
)?;
let request = authenticated_request(config, Method::GET, &url, auth).await?;
send_and_decode(request, &url).await
}
@@ -414,17 +404,14 @@ async fn create_workspace_plugin_upload(
) -> Result<RemoteWorkspacePluginUploadUrlResponse, RemotePluginCatalogError> {
let base_url = config.chatgpt_base_url.trim_end_matches('/');
let url = format!("{base_url}/public/plugins/workspace/upload-url");
let request = authenticated_request(
config.http_request(Method::POST, &url),
auth,
&config.product_sku,
)?
.json(&RemoteWorkspacePluginUploadUrlRequest {
filename,
mime_type: "application/gzip",
size_bytes,
plugin_id: remote_plugin_id,
});
let request = authenticated_request(config, Method::POST, &url, auth)
.await?
.json(&RemoteWorkspacePluginUploadUrlRequest {
filename,
mime_type: "application/gzip",
size_bytes,
plugin_id: remote_plugin_id,
});
send_and_decode(request, &url).await
}
@@ -476,12 +463,9 @@ async fn finalize_workspace_plugin_upload(
} else {
format!("{base_url}/public/plugins/workspace")
};
let request = authenticated_request(
config.http_request(Method::POST, &url),
auth,
&config.product_sku,
)?
.json(&body);
let request = authenticated_request(config, Method::POST, &url, auth)
.await?
.json(&body);
send_and_decode(request, &url).await
}
@@ -40,6 +40,7 @@ pub async fn checkout_remote_plugin_share(
codex_home: &Path,
remote_plugin_id: &str,
) -> Result<RemotePluginShareCheckoutResult, RemotePluginCatalogError> {
let config = &config.for_current_account();
let detail = super::super::fetch_remote_plugin_detail_with_download_urls(
config,
auth,