Extract WebSocket authentication into codex-websocket-auth (#47447)

## What changed

Move WebSocket authentication arguments, settings, credential loading, and upgrade authorization into a shared crate using `http` types. Update the app server, transport, and CLI to consume it directly, and remove the `AppServer` prefix from the shared types.

Hide token digests and JWT verification secrets from authentication policy `Debug` output.

## Testing

Move the existing argument validation, capability-token authorization, and signed bearer-token verification tests into the new crate.

GitOrigin-RevId: 1dd20043a3f8efbca55af7eda338b62a62e8fd68
This commit is contained in:
Ruslan Nigmatullin
2026-09-23 04:25:28 +00:00
committed by copyberry
parent 4981037e99
commit c44deff7b1
18 changed files with 422 additions and 361 deletions
+3 -3
View File
@@ -602,7 +602,7 @@ struct AppServerCommand {
analytics_default_enabled: bool,
#[command(flatten)]
auth: codex_app_server::AppServerWebsocketAuthArgs,
auth: codex_websocket_auth::WebsocketAuthArgs,
}
#[derive(Debug, clap::Subcommand)]
@@ -4718,7 +4718,7 @@ mod tests {
);
assert_eq!(
app_server.auth.ws_auth,
Some(codex_app_server::WebsocketAuthCliMode::CapabilityToken)
Some(codex_websocket_auth::WebsocketAuthCliMode::CapabilityToken)
);
assert_eq!(
app_server.auth.ws_token_file,
@@ -4747,7 +4747,7 @@ mod tests {
);
assert_eq!(
app_server.auth.ws_auth,
Some(codex_app_server::WebsocketAuthCliMode::SignedBearerToken)
Some(codex_websocket_auth::WebsocketAuthCliMode::SignedBearerToken)
);
assert_eq!(
app_server.auth.ws_shared_secret_file,
+2 -2
View File
@@ -5,7 +5,6 @@ use anyhow::Context;
use clap::Args;
use codex_app_server::AppServerRuntimeOptions;
use codex_app_server::AppServerTransport;
use codex_app_server::AppServerWebsocketAuthSettings;
use codex_app_server_daemon::LifecycleCommand as AppServerLifecycleCommand;
use codex_app_server_daemon::LifecycleOutput as AppServerLifecycleOutput;
use codex_app_server_daemon::LifecycleStatus as AppServerLifecycleStatus;
@@ -19,6 +18,7 @@ use codex_config::LoaderOverrides;
use codex_protocol::protocol::SessionSource;
use codex_utils_absolute_path::AbsolutePathBuf;
use codex_utils_cli::CliConfigOverrides;
use codex_websocket_auth::WebsocketAuthSettings;
use serde::Serialize;
use tokio::sync::watch;
use tokio::task::JoinHandle;
@@ -137,7 +137,7 @@ async fn run_foreground_remote_control(
/*default_analytics_enabled*/ false,
transport,
SessionSource::VSCode,
AppServerWebsocketAuthSettings::default(),
WebsocketAuthSettings::default(),
runtime_options,
);
let mut app_server_task = tokio::spawn(async move { app_server.await.map(|_| ()) });