mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Wire app-server user verification RPCs to the native provider (#43568)
## Why The existing `userVerification/*` handlers always returned unavailability, leaving local clients unable to use the native verification provider. ## What changed - Dispatch status, enrollment, deletion, and challenge signing through an account-scoped provider. Enrollment creates or reuses a local key; it does not register credentials with a server. - Restrict enrollment, deletion, and signing to stdio and in-process connections, rejecting WebSocket and remote-control callers before parameter validation. - Bound native work to one operation per service with a 120-second timeout, and propagate in-process caller cancellation. Recheck connection, cancellation, and authentication state before delivering results, including after waiting for response queue capacity. - Add device-gated verification capability wiring for the experimental in-process `codex-tui` client, with automatic activation still disabled by default. ## Testing Add tests for local key reuse and deletion, decoded challenge signing, cancellation, authentication changes during verification and response queuing, concurrent worker rejection, and stdio/WebSocket RPC behavior. GitOrigin-RevId: 7eac15a5ffb049d27bf8fedcfbae19a49a3f6a3d
This commit is contained in:
1 parent
daca1fab84
commit
ca6fb194b6
14 files changed
+1185
-23
No files matched your search
@@ -8,6 +8,8 @@ use codex_login::default_client::USER_AGENT_SUFFIX;
|
||||
use codex_login::default_client::get_codex_user_agent;
|
||||
use codex_login::default_client::set_default_client_residency_requirement;
|
||||
use codex_login::default_client::set_default_originator;
|
||||
use codex_protocol::mcp::ClientMcpExtensions;
|
||||
use codex_protocol::mcp::OPENAI_ELICITATION_EXTENSION_ID;
|
||||
|
||||
use super::*;
|
||||
use crate::message_processor::ConnectionSessionState;
|
||||
@@ -22,6 +24,7 @@ pub(crate) struct InitializeRequestProcessor {
|
||||
config: Arc<Config>,
|
||||
config_warnings: Arc<Vec<ConfigWarningNotification>>,
|
||||
rpc_transport: AppServerRpcTransport,
|
||||
user_verification: Arc<crate::user_verification::Service>,
|
||||
}
|
||||
|
||||
impl InitializeRequestProcessor {
|
||||
@@ -31,6 +34,7 @@ impl InitializeRequestProcessor {
|
||||
config: Arc<Config>,
|
||||
config_warnings: Vec<ConfigWarningNotification>,
|
||||
rpc_transport: AppServerRpcTransport,
|
||||
user_verification: Arc<crate::user_verification::Service>,
|
||||
) -> Self {
|
||||
Self {
|
||||
outgoing,
|
||||
@@ -38,6 +42,7 @@ impl InitializeRequestProcessor {
|
||||
config,
|
||||
config_warnings: Arc::new(config_warnings),
|
||||
rpc_transport,
|
||||
user_verification,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +76,7 @@ impl InitializeRequestProcessor {
|
||||
let experimental_api_enabled = capabilities.experimental_api;
|
||||
let request_attestation = capabilities.request_attestation;
|
||||
let extensions = capabilities.extensions.as_ref();
|
||||
let client_mcp_extensions = codex_mcp::client_mcp_extensions(
|
||||
let mut client_mcp_extensions = codex_mcp::client_mcp_extensions(
|
||||
extensions,
|
||||
capabilities.mcp_server_openai_form_elicitation,
|
||||
);
|
||||
@@ -90,6 +95,31 @@ impl InitializeRequestProcessor {
|
||||
"Invalid clientInfo.name: '{name}'. Must be a valid HTTP header value."
|
||||
)));
|
||||
}
|
||||
// The bundled TUI shares this build and implements the typed verification UI.
|
||||
// Independently deployed UIs need their own rollout before receiving this mode.
|
||||
let user_verification_enabled = experimental_api_enabled
|
||||
&& matches!(
|
||||
session.origin,
|
||||
crate::transport::ConnectionOrigin::InProcess
|
||||
)
|
||||
&& name == "codex-tui"
|
||||
&& tokio::task::spawn_blocking(self.user_verification.device_supported)
|
||||
.await
|
||||
.unwrap_or(false);
|
||||
if user_verification_enabled {
|
||||
let mut extensions = client_mcp_extensions
|
||||
.iter()
|
||||
.map(|(id, value)| (id.to_string(), value.clone()))
|
||||
.collect::<std::collections::HashMap<_, _>>();
|
||||
let settings = extensions
|
||||
.entry(OPENAI_ELICITATION_EXTENSION_ID.to_string())
|
||||
.or_insert_with(|| serde_json::json!({}));
|
||||
if !settings.is_object() {
|
||||
*settings = serde_json::json!({});
|
||||
}
|
||||
settings["userVerification"] = serde_json::json!({});
|
||||
client_mcp_extensions = ClientMcpExtensions::new(extensions);
|
||||
}
|
||||
let originator = name.clone();
|
||||
let user_agent_suffix = format!("{name}; {version}");
|
||||
let mutates_global_identity = !NON_ORIGINATING_CLIENT_NAMES.contains(&name.as_str());
|
||||
@@ -107,6 +137,11 @@ impl InitializeRequestProcessor {
|
||||
{
|
||||
return Err(invalid_request("Already initialized"));
|
||||
}
|
||||
if user_verification_enabled {
|
||||
self.outgoing
|
||||
.enable_user_verification_connection(connection_id)
|
||||
.await;
|
||||
}
|
||||
|
||||
if mutates_global_identity {
|
||||
// Only real client initialization may mutate process-global client metadata.
|
||||
|
||||
Reference in new issue
Block a user