mirror of
https://github.com/openai/codex.git
synced 2026-11-22 07:13:50 +00:00
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:
1 parent
2013e04354
commit
fc6268ad38
37 files changed
+448
-320
No files matched your search
@@ -448,7 +448,7 @@ pub struct PluginsManager {
|
||||
remote_installed_plugins_cache_refresh_state: RwLock<RemoteInstalledPluginsCacheRefreshState>,
|
||||
remote_catalog_cache_refresh_state: RwLock<RemoteCatalogCacheRefreshState>,
|
||||
restriction_product: Option<Product>,
|
||||
auth_mode: RwLock<Option<AuthMode>>,
|
||||
auth_manager: Arc<AuthManager>,
|
||||
analytics_events_client: RwLock<Option<AnalyticsEventsClient>>,
|
||||
plugin_install_source: PluginInstallSource,
|
||||
}
|
||||
@@ -501,13 +501,13 @@ fn target_curated_marketplace(auth_mode: Option<AuthMode>) -> TargetCuratedMarke
|
||||
impl PluginsManager {
|
||||
pub fn new(
|
||||
codex_home: PathBuf,
|
||||
auth_mode: Option<AuthMode>,
|
||||
auth_manager: Arc<AuthManager>,
|
||||
skill_root_loader: Arc<dyn SkillRootLoader<PluginSkillRoot>>,
|
||||
) -> Self {
|
||||
Self::new_with_options(
|
||||
codex_home,
|
||||
Some(Product::Codex),
|
||||
auth_mode,
|
||||
auth_manager,
|
||||
skill_root_loader,
|
||||
)
|
||||
}
|
||||
@@ -515,7 +515,7 @@ impl PluginsManager {
|
||||
pub fn new_with_options(
|
||||
codex_home: PathBuf,
|
||||
restriction_product: Option<Product>,
|
||||
auth_mode: Option<AuthMode>,
|
||||
auth_manager: Arc<AuthManager>,
|
||||
skill_root_loader: Arc<dyn SkillRootLoader<PluginSkillRoot>>,
|
||||
) -> Self {
|
||||
// Product restrictions are enforced at marketplace admission time for a given CODEX_HOME:
|
||||
@@ -552,7 +552,7 @@ impl PluginsManager {
|
||||
RemoteCatalogCacheRefreshState::default(),
|
||||
),
|
||||
restriction_product,
|
||||
auth_mode: RwLock::new(auth_mode),
|
||||
auth_manager,
|
||||
analytics_events_client: RwLock::new(None),
|
||||
plugin_install_source: PluginInstallSource::Manual,
|
||||
}
|
||||
@@ -563,23 +563,8 @@ impl PluginsManager {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_auth_mode(&self, auth_mode: Option<AuthMode>) -> bool {
|
||||
let mut stored_auth_mode = match self.auth_mode.write() {
|
||||
Ok(auth_mode_guard) => auth_mode_guard,
|
||||
Err(err) => err.into_inner(),
|
||||
};
|
||||
if *stored_auth_mode == auth_mode {
|
||||
return false;
|
||||
}
|
||||
*stored_auth_mode = auth_mode;
|
||||
true
|
||||
}
|
||||
|
||||
pub fn auth_mode(&self) -> Option<AuthMode> {
|
||||
match self.auth_mode.read() {
|
||||
Ok(auth_mode_guard) => *auth_mode_guard,
|
||||
Err(err) => *err.into_inner(),
|
||||
}
|
||||
self.auth_manager.get_api_auth_mode()
|
||||
}
|
||||
|
||||
fn remote_global_catalog_active(&self, config: &PluginsConfigInput) -> bool {
|
||||
@@ -2118,7 +2103,6 @@ impl PluginsManager {
|
||||
pub fn maybe_start_plugin_startup_tasks_for_config(
|
||||
self: &Arc<Self>,
|
||||
config: &PluginsConfigInput,
|
||||
auth_manager: Arc<AuthManager>,
|
||||
on_effective_plugins_changed: Option<EffectivePluginsChangedCallback>,
|
||||
) {
|
||||
if config.plugins_enabled {
|
||||
@@ -2191,10 +2175,9 @@ impl PluginsManager {
|
||||
}
|
||||
let config_for_remote_sync = config.clone();
|
||||
let manager = Arc::clone(self);
|
||||
let auth_manager_for_remote_sync = auth_manager.clone();
|
||||
let on_effective_plugins_changed = on_effective_plugins_changed.clone();
|
||||
tokio::spawn(async move {
|
||||
let auth = auth_manager_for_remote_sync.auth().await;
|
||||
let auth = manager.auth_manager.auth().await;
|
||||
manager.maybe_start_remote_plugin_caches_refresh(
|
||||
&config_for_remote_sync,
|
||||
auth.clone(),
|
||||
@@ -2226,7 +2209,7 @@ impl PluginsManager {
|
||||
let config_for_featured_plugins = config.clone();
|
||||
let manager = Arc::clone(self);
|
||||
tokio::spawn(async move {
|
||||
let auth = auth_manager.auth().await;
|
||||
let auth = manager.auth_manager.auth().await;
|
||||
if let Err(err) = manager
|
||||
.featured_plugin_ids_for_config(&config_for_featured_plugins, auth.as_ref())
|
||||
.await
|
||||
|
||||
Reference in new issue
Block a user