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:
riley-oai authored and copyberry committed 2026-09-07 19:34:23 +00:00
1 parent daca1fab84
commit ca6fb194b6
14 files changed
+1185 -23

No files matched your search

+15 -5
View File
@@ -188,6 +188,7 @@ enum InProcessClientMessage {
Request {
request: Box<ClientRequest>,
response_tx: oneshot::Sender<PendingClientRequestResponse>,
cancellation: tokio_util::sync::CancellationToken,
},
Notification {
notification: ClientNotification,
@@ -206,7 +207,7 @@ enum InProcessClientMessage {
}
enum ProcessorCommand {
Request(Box<ClientRequest>),
Request(Box<ClientRequest>, tokio_util::sync::CancellationToken),
Notification(ClientNotification),
}
@@ -218,9 +219,12 @@ pub struct InProcessClientSender {
impl InProcessClientSender {
pub async fn request(&self, request: ClientRequest) -> IoResult<PendingClientRequestResponse> {
let (response_tx, response_rx) = oneshot::channel();
let cancellation = tokio_util::sync::CancellationToken::new();
let _cancel_on_drop = cancellation.clone().drop_guard();
self.try_send_client_message(InProcessClientMessage::Request {
request: Box::new(request),
response_tx,
cancellation,
})?;
response_rx.await.map_err(|err| {
IoError::new(
@@ -482,6 +486,9 @@ async fn start_uninitialized(args: InProcessStartArgs) -> IoResult<InProcessClie
state_db: args.state_db,
config_warnings: args.config_warnings,
session_source: args.session_source,
user_verification: Arc::new(crate::user_verification::Service::new(Arc::clone(
&auth_manager,
))),
auth_manager,
installation_id,
code_mode_session_provider: None,
@@ -490,14 +497,16 @@ async fn start_uninitialized(args: InProcessStartArgs) -> IoResult<InProcessClie
plugin_startup_tasks: Some(PluginStartupConfig::Current),
}));
let mut thread_created_rx = processor.thread_created_receiver();
let session = Arc::new(ConnectionSessionState::new());
let session = Arc::new(ConnectionSessionState::new(
crate::transport::ConnectionOrigin::InProcess,
));
let mut listen_for_threads = true;
loop {
tokio::select! {
command = processor_rx.recv() => {
match command {
Some(ProcessorCommand::Request(request)) => {
Some(ProcessorCommand::Request(request, cancellation)) => {
let was_initialized = session.initialized();
processor
.process_client_request(
@@ -505,6 +514,7 @@ async fn start_uninitialized(args: InProcessStartArgs) -> IoResult<InProcessClie
*request,
Arc::clone(&session),
&outbound_initialized,
cancellation,
)
.await;
let opted_out_notification_methods_snapshot =
@@ -576,7 +586,7 @@ async fn start_uninitialized(args: InProcessStartArgs) -> IoResult<InProcessClie
tokio::select! {
message = client_rx.recv() => {
match message {
Some(InProcessClientMessage::Request { request, response_tx }) => {
Some(InProcessClientMessage::Request { request, response_tx, cancellation }) => {
let request = *request;
let request_id = request.id().clone();
match pending_request_responses.entry(request_id.clone()) {
@@ -591,7 +601,7 @@ async fn start_uninitialized(args: InProcessStartArgs) -> IoResult<InProcessClie
}
}
match processor_tx.try_send(ProcessorCommand::Request(Box::new(request))) {
match processor_tx.try_send(ProcessorCommand::Request(Box::new(request), cancellation)) {
Ok(()) => {}
Err(mpsc::error::TrySendError::Full(_)) => {
if let Some(response_tx) =