Enable configuration server OAuth during app-server startup (#62867)

## Why

When an organization's configuration server requires a new OAuth grant,
clients need a way to sign in before the app server starts so they can
load and validate the required settings.

## What changed

- Have `--print-startup-config` return the `configServerLogin` action
  when browser sign-in is required, and verify that the required server
  settings were applied before returning startup requirements.
- Add `codex app-server --startup-oauth`, a dedicated stdio mode that
  resolves the configuration server from local managed requirements,
  sends the client a browser authorization URL, and handles the callback,
  token exchange, and credential storage. Clients can cancel a pending
  sign-in or rerun `--print-startup-config` after it succeeds.

## Testing

Add a test that checks the browser handoff URL and verifies that
cancellation completes the pending login request with `LoginFailed`.

GitOrigin-RevId: 00f10d28befe33539882f4f3c0d2baf868ceb4a1
This commit is contained in:
arnavpatidar-OAI
2026-11-21 00:03:42 +00:00
committed by copyberry
parent f342aa7b92
commit cf8992e940
8 changed files with 470 additions and 52 deletions
+2 -2
View File
@@ -1310,10 +1310,10 @@ async fn dispatch_cli(
root_remote_auth_token_env.as_deref(),
subcommand.as_ref(),
)?;
if startup_config.print_startup_config {
if startup_config.print_startup_config || startup_config.startup_oauth {
anyhow::ensure!(
subcommand.is_none(),
"--print-startup-config cannot run a subcommand"
"startup configuration modes cannot run a subcommand"
);
codex_app_server::print_startup_config(
arg0_paths,