Add trusted enterprise MCP auth configuration (#44832)

## Why

Enterprise MCP authorization must remain controlled by host, user, or managed configuration. Project settings and plugin declarations must not redirect enterprise credentials or downgrade the selected authentication mode.

## What changed

- Add `auth = "ema_auth"`, shared `mcp_enterprise_managed_auth` IdP configuration, and per-plugin enterprise registration settings.
- Require enterprise registrations to come from one non-project configuration layer, preserve managed IdP precedence, and reject project overrides that change authorization or re-enable disabled enterprise servers.
- Add the disabled-by-default `use_xaa` feature flag and require non-project opt-in or a managed requirement.
- Reject plugin declarations that select `ema_auth`. Keep EMA connections unsupported and block ordinary MCP OAuth login and credential fallback for this mode.
- Extend the configuration schema and serialization for the new settings.

## Testing

Add coverage for IdP precedence, incomplete registrations, alternate credential validation, project-only opt-in, plugin self-declaration rejection, configuration round-tripping, and trusted-project attempts to downgrade enterprise auth to OAuth or ChatGPT auth.

GitOrigin-RevId: f193bdfda74208c98e496a23bf2916955b131a1c
This commit is contained in:
Nick Steele
2026-09-11 14:25:56 +00:00
committed by copyberry
parent 7a6f469dcf
commit 654b0a77d0
28 changed files with 872 additions and 31 deletions
+7
View File
@@ -406,6 +406,7 @@ async fn run_add(config_overrides: &CliConfigOverrides, add_args: AddArgs) -> Re
client_id: Some(client_id),
callback_url: callback_url.clone(),
callback_port: None,
..Default::default()
}),
oauth_resource: oauth_resource.clone(),
tools: HashMap::new(),
@@ -525,6 +526,12 @@ async fn run_login(config: &Config, login_args: LoginArgs) -> Result<()> {
bail!("No MCP server named '{name}' found.");
};
if matches!(server.auth, codex_config::types::McpServerAuth::EmaAuth) {
bail!(
"Enterprise MCP authorization is managed by Codex account sign-in. Open Codex to sign in."
);
}
let (url, http_headers, env_http_headers) = match &server.transport {
McpServerTransportConfig::StreamableHttp {
url,