Skip to content

app-server: centralize AuthManager initialization#16764

Merged
euroelessar merged 4 commits intomainfrom
ruslan/app-server-auth-manager-init
Apr 6, 2026
Merged

app-server: centralize AuthManager initialization#16764
euroelessar merged 4 commits intomainfrom
ruslan/app-server-auth-manager-init

Conversation

@euroelessar
Copy link
Copy Markdown
Collaborator

Extract a shared helper that builds AuthManager from Config and applies the forced ChatGPT workspace override in one place.

Create the shared AuthManager at MessageProcessor call sites so that upcoming new transport's initialization can reuse the same handle, and keep only external auth refresher wiring inside MessageProcessor.

Remove the now-unused AuthManager::shared_with_external_auth helper.

Extract a shared helper that builds AuthManager from Config and applies the forced ChatGPT workspace override in one place.

Create the shared AuthManager at MessageProcessor call sites so transport startup can reuse the same handle, and keep only external auth refresher wiring inside MessageProcessor.

Remove the now-unused AuthManager::shared_with_external_auth helper.
Copy link
Copy Markdown
Collaborator

@owenlin0 owenlin0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pre-approving

pub(crate) fn auth_manager_from_config(
config: &Config,
enable_codex_api_key_env: bool,
) -> Arc<AuthManager> {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't seem specific to app-server, is there a better home for it? could we do something along these lines?

// codex-config or codex-login
pub struct AuthManagerConfig {
    pub codex_home: PathBuf,
    pub credentials_store_mode: AuthCredentialsStoreMode,
    pub forced_chatgpt_workspace_id: Option<String>,
}

// codex-login
impl AuthManager {
    pub fn shared_from_config(
        config: &AuthManagerConfig,
        enable_codex_api_key_env: bool,
    ) -> Arc<Self> {
        let auth_manager = Self::shared(
            config.codex_home.clone(),
            enable_codex_api_key_env,
            config.credentials_store_mode,
        );
        auth_manager.set_forced_chatgpt_workspace_id(
            config.forced_chatgpt_workspace_id.clone(),
        );
        auth_manager
    }
}

a shared helper will help since apparently we have this in a bunch of places:

  • core/src/connectors.rs (line 495) constructs an AuthManager but does not set forced_chatgpt_workspace_id.
  • core/src/prompt_debug.rs (line 26) does set it.
  • mcp-server also constructs one inline in mcp-server/src/message_processor.rs.

@euroelessar euroelessar merged commit 1525bbd into main Apr 6, 2026
28 of 31 checks passed
@euroelessar euroelessar deleted the ruslan/app-server-auth-manager-init branch April 6, 2026 19:46
@github-actions github-actions bot locked and limited conversation to collaborators Apr 6, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants