app-server: centralize AuthManager initialization#16764
Merged
euroelessar merged 4 commits intomainfrom Apr 6, 2026
Merged
Conversation
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.
owenlin0
approved these changes
Apr 6, 2026
| pub(crate) fn auth_manager_from_config( | ||
| config: &Config, | ||
| enable_codex_api_key_env: bool, | ||
| ) -> Arc<AuthManager> { |
Collaborator
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_authhelper.