Integrate config-server policies with startup and authentication (#57175)

## What changed

- Use the managed configuration loader in CLI, exec, TUI, and app-server configuration flows so `requirements.toml` can select a config server.
- Sign in to the config server when needed during interactive TUI startup and CLI login, reload configuration after CLI sign-in, and clear config-server credentials on CLI logout.
- Preserve the app-server's config-server settings and refresh worker across OpenAI login and logout.
- Require config-server settings to be applied when loading CLI and doctor configuration.

## Testing

Add app-server integration tests using a local HTTPS config server to verify managed provider and instruction settings at startup, preservation across API-key login and logout, and cache reuse after restart and thread resume.

GitOrigin-RevId: 27ee81f7943d2290a5c3fcc0ac556579ec63f8b4
This commit is contained in:
smurching-oai
2026-10-26 18:14:57 +00:00
committed by copyberry
parent 619531225b
commit ec513795a6
13 changed files with 401 additions and 39 deletions
@@ -25,6 +25,27 @@ pub fn managed_config_auth_manager(
crate::config_server_auth_manager(service_config, auth.codex_home, &factory)
}
/// Existing grants are left to the loader's normal cache and refresh handling.
pub async fn ensure_config_server_login(
auth: AuthConfig,
requirements: &ConfigRequirementsToml,
) -> std::io::Result<()> {
let Some(manager) = managed_config_auth_manager(auth, requirements)? else {
return Ok(());
};
if let Err(error) = manager.authorization_id().await {
if error
.get_ref()
.and_then(|source| source.downcast_ref::<codex_login::OAuthSessionError>())
!= Some(&codex_login::OAuthSessionError::LoginRequired)
{
return Err(error);
}
manager.login().await?;
}
Ok(())
}
pub fn managed_config_bundle_loader(
auth_manager: Arc<AuthManager>,
chatgpt_base_url: String,