MCPcopy Index your code
hub / github.com/ChrisFeldmeier/OpenCodeRust / load_plugin_auth_store

Function load_plugin_auth_store

crates/opencode-server/src/server.rs:343–418  ·  view source on GitHub ↗
(server_url: &str, auth_manager: Arc<AuthManager>)

Source from the content-addressed store, hash-verified

341}
342
343async fn load_plugin_auth_store(server_url: &str, auth_manager: Arc<AuthManager>) {
344 let cwd = match std::env::current_dir() {
345 Ok(cwd) => cwd,
346 Err(error) => {
347 tracing::warn!(%error, "failed to get current directory for plugin bootstrap");
348 return;
349 }
350 };
351
352 let config = match load_config(&cwd) {
353 Ok(config) => config,
354 Err(error) => {
355 tracing::warn!(%error, "failed to load config for plugin bootstrap");
356 return;
357 }
358 };
359
360 let loader = match PluginLoader::new() {
361 Ok(loader) => Arc::new(loader),
362 Err(error) => {
363 tracing::warn!(%error, "failed to initialize plugin loader");
364 return;
365 }
366 };
367 init_global(loader.hook_system());
368
369 let directory = cwd.to_string_lossy().to_string();
370 let context = PluginContext {
371 worktree: directory.clone(),
372 directory,
373 server_url: server_url.to_string(),
374 };
375
376 if let Err(error) = loader.load_builtins(&context).await {
377 tracing::warn!(%error, "failed to load builtin auth plugins");
378 }
379
380 if !config.plugin.is_empty() {
381 if let Err(error) = loader.load_all(&config.plugin, &context).await {
382 tracing::warn!(%error, "failed to load configured plugins");
383 return;
384 }
385 }
386
387 routes::set_plugin_loader(loader.clone());
388
389 let bridges = loader.auth_bridges().await;
390 for (provider_id, bridge) in bridges {
391 match bridge.load().await {
392 Ok(result) => {
393 sync_custom_fetch_proxy(&provider_id, bridge.clone(), result.has_custom_fetch);
394
395 if let Some(api_key) = result.api_key {
396 auth_manager
397 .set(
398 &provider_id,
399 AuthInfo::Api {
400 key: api_key.clone(),

Callers 1

Calls 13

load_configFunction · 0.85
newFunction · 0.85
init_globalFunction · 0.85
set_plugin_loaderFunction · 0.85
sync_custom_fetch_proxyFunction · 0.85
load_builtinsMethod · 0.80
is_emptyMethod · 0.80
auth_bridgesMethod · 0.80
hook_systemMethod · 0.45
cloneMethod · 0.45
load_allMethod · 0.45
loadMethod · 0.45

Tested by

no test coverage detected