Read plugin authentication state from AuthManager (#39087)

## What changed

- Give `PluginsManager` a shared `AuthManager` instead of a separately mutable authentication-mode snapshot.
- Read the current authentication mode and credentials from that shared manager for plugin discovery, startup tasks, CLI commands, MCP setup, and external-agent migration.
- Update test helpers and coverage to exercise plugin projections and curated marketplace selection as authentication changes.

GitOrigin-RevId: 600c94de5130eda2da5727e1a0b4d39083fefc56
This commit is contained in:
willwang-openai authored and copyberry committed 2026-08-17 22:26:27 +00:00
1 parent 2013e04354
commit fc6268ad38
37 files changed
+448 -320

No files matched your search

+6 -1
View File
@@ -2145,8 +2145,13 @@ impl AuthManager {
/// Create an AuthManager with a specific CodexAuth, for testing only.
pub fn from_auth_for_testing(auth: CodexAuth) -> Arc<Self> {
Self::from_optional_auth_for_testing(Some(auth))
}
/// Create an AuthManager with an optional CodexAuth, for testing only.
pub(crate) fn from_optional_auth_for_testing(auth: Option<CodexAuth>) -> Arc<Self> {
let cached = CachedAuth {
auth: Some(auth),
auth,
permanent_refresh_failure: None,
};
let (auth_change_tx, _auth_change_rx) = watch::channel(0);
+35
View File
@@ -3,9 +3,44 @@
//! Production code should receive an [`AuthRouteConfig`](crate::AuthRouteConfig) adapted from the
//! application's resolved HTTP client factory instead of depending on this module.
use crate::AuthManager;
use crate::AuthRouteConfig;
use crate::CodexAuth;
use crate::auth::AgentIdentityAuth;
use crate::auth::AgentIdentityAuthRecord;
use codex_http_client::HttpClientFactory;
use codex_http_client::OutboundProxyPolicy;
use codex_protocol::account::PlanType as AccountPlanType;
use std::sync::Arc;
/// Creates an authentication manager with optional credentials for cross-crate tests.
pub fn auth_manager_from_optional_auth(auth: Option<CodexAuth>) -> Arc<AuthManager> {
AuthManager::from_optional_auth_for_testing(auth)
}
/// Creates an authentication manager with initialized Agent Identity credentials for tests.
pub async fn auth_manager_with_agent_identity() -> std::io::Result<Arc<AuthManager>> {
let key_material =
codex_agent_identity::generate_agent_key_material().map_err(std::io::Error::other)?;
let auth = AgentIdentityAuth::from_record(
AgentIdentityAuthRecord {
agent_runtime_id: "test-agent-runtime-id".to_string(),
agent_private_key: key_material.private_key_pkcs8_base64,
account_id: "test-account-id".to_string(),
chatgpt_user_id: "test-user-id".to_string(),
email: Some("test-user@example.com".to_string()),
plan_type: AccountPlanType::Pro,
chatgpt_account_is_fedramp: false,
task_id: Some("test-task-id".to_string()),
},
"https://unused.invalid",
&transport_default_auth_route_config(),
)
.await?;
Ok(auth_manager_from_optional_auth(Some(
CodexAuth::AgentIdentity(auth),
)))
}
/// Returns auth routing that preserves the transport's built-in proxy behavior.
pub fn transport_default_auth_route_config() -> AuthRouteConfig {