mirror of
https://github.com/openai/codex.git
synced 2026-11-14 21:40:39 +00:00
Use runtime authentication for OpenAI MCP and app requests (#59749)
## What changed - Select fresh authentication for each HTTP operation on eligible OpenAI MCP connections while preserving the connection's credential source and account network policy. Stop redirects when requests carry runtime assertions. - Pass the owning thread's authentication and runtime context through app discovery, connector metadata, and trusted-access requests. Include the runtime authentication mode in MCP connection and tool-cache identities. - Give resumed actors analytics clients bound to their own authentication context, and serialize stored-credential reloads with token refresh while preserving host-provided credentials. ## Testing Add coverage for fresh request assertions, revoked account policies, redirect handling, resumed-actor isolation, and MCP uploads in dual-header and assertion-only modes. GitOrigin-RevId: f06900a6db61cd6cf53c3aa8075afeec4d5706d9
This commit is contained in:
@@ -58,12 +58,14 @@ impl AppsRequestProcessor {
|
||||
None,
|
||||
),
|
||||
};
|
||||
let auth = self.auth_manager.auth().await;
|
||||
let mcp_manager = thread.as_ref().map(|thread| thread.mcp_manager())
|
||||
.unwrap_or_else(|| self.thread_manager.mcp_manager());
|
||||
let auth_manager = mcp_manager.auth_manager();
|
||||
let auth = auth_manager.auth().await;
|
||||
let runtime_enabled = config
|
||||
.features
|
||||
.apps_enabled_for_auth(auth.as_ref().is_some_and(CodexAuth::uses_codex_backend));
|
||||
|
||||
let mcp_manager = self.thread_manager.mcp_manager();
|
||||
let cache_key = connector_runtime_context_key(auth.as_ref());
|
||||
let previous_snapshot = mcp_manager
|
||||
.codex_apps_tools_cache()
|
||||
@@ -96,9 +98,11 @@ impl AppsRequestProcessor {
|
||||
let cancellation_token = CancellationToken::new();
|
||||
let codex_apps_auth_manager =
|
||||
host_owned_codex_apps_enabled(&mcp_config, auth.as_ref())
|
||||
.then(|| Arc::clone(&self.auth_manager));
|
||||
.then(|| Arc::clone(&auth_manager));
|
||||
self.thread_manager.runtime_auth_for_mcp_manager(&config, &mcp_manager)?;
|
||||
let runtime = McpRuntime::new(McpRuntimeInput {
|
||||
network_policy_metadata: None,
|
||||
runtime_auth: mcp_manager.runtime_auth_for_config(&config),
|
||||
startup_policy: McpStartupPolicy::Eager,
|
||||
config: Arc::clone(&mcp_config),
|
||||
plugins_available: false,
|
||||
|
||||
@@ -26,14 +26,22 @@ impl AppsRequestProcessor {
|
||||
.into_iter()
|
||||
.filter(|app_id| seen_app_ids.insert(app_id.clone()))
|
||||
.collect::<Vec<_>>();
|
||||
let mut config = self.load_apps_config(thread_id.as_deref()).await?;
|
||||
let auth = match self.auth_manager.auth_with_http_client_factory().await {
|
||||
let (mut config, mcp_manager) = self.load_apps_config(thread_id.as_deref()).await?;
|
||||
let auth = match mcp_manager
|
||||
.auth_manager()
|
||||
.auth_with_http_client_factory()
|
||||
.await
|
||||
{
|
||||
Some((auth, factory)) => {
|
||||
config.application_network_policy = factory.network_policy().clone();
|
||||
Some(auth)
|
||||
}
|
||||
None => None,
|
||||
};
|
||||
let runtime = self
|
||||
.thread_manager
|
||||
.runtime_auth_for_mcp_manager(&config, &mcp_manager)
|
||||
.map_err(|error| internal_error(error.to_string()))?;
|
||||
if !config
|
||||
.features
|
||||
.apps_enabled_for_auth(auth.as_ref().is_some_and(CodexAuth::uses_codex_backend))
|
||||
@@ -52,11 +60,16 @@ impl AppsRequestProcessor {
|
||||
let connectors::ConnectorMetadataReadResult {
|
||||
apps,
|
||||
missing_app_ids,
|
||||
} = connectors::read_connector_metadata(&config, auth, &app_ids, include_tools)
|
||||
.await
|
||||
.map_err(|err| internal_error(format!("failed to read app metadata: {err}")))?;
|
||||
let loaded_plugins = self
|
||||
.thread_manager
|
||||
} = connectors::read_connector_metadata(
|
||||
&config,
|
||||
auth,
|
||||
runtime.as_ref(),
|
||||
&app_ids,
|
||||
include_tools,
|
||||
)
|
||||
.await
|
||||
.map_err(|err| internal_error(format!("failed to read app metadata: {err}")))?;
|
||||
let loaded_plugins = mcp_manager
|
||||
.plugins_manager()
|
||||
.plugins_for_config(&config.plugins_config_input())
|
||||
.await;
|
||||
|
||||
Reference in New Issue
Block a user