mirror of
https://github.com/openai/codex.git
synced 2026-11-24 15:21:20 +00:00
Bind remote-control sessions to their authentication owner (#44341)
## Why Remote-control connections and queued operations must not carry over to a different signed-in user or account. Token refreshes for the same identity should preserve the live relay connection. ## What changed - Scope relay state and authentication recovery to a login lifetime. Retire the session on logout or identity changes and leave remote control disabled until enabled again. - Reject stale incoming messages and queued RPCs, and cancel pending remote-control operations when their authentication owner changes. - Start replacement sessions with fresh client, replay, and enrollment state, and prevent retired sessions from publishing status into their replacements. - Serialize enrollment and preference persistence across sessions, retaining write permits through caller cancellation and draining admitted writes on shutdown. ## Testing Add regression coverage for same-owner refreshes, user and account changes, stale pairing and client-revocation work, unauthorized enrollment recovery after logging in again, and persistence during cancellation. GitOrigin-RevId: 5e6ecd23588aab1e2e6168a21f575fb24bbb341c
This commit is contained in:
1 parent
d390f0a09c
commit
1bff94edb6
24 files changed
+1487
-441
No files matched your search
@@ -1087,6 +1087,7 @@ pub async fn run_main_with_transport_options(
|
||||
TransportEvent::ConnectionOpened {
|
||||
connection_id,
|
||||
origin,
|
||||
auth,
|
||||
writer,
|
||||
disconnect_sender,
|
||||
} => {
|
||||
@@ -1117,6 +1118,7 @@ pub async fn run_main_with_transport_options(
|
||||
connection_id,
|
||||
ConnectionState::new(
|
||||
origin,
|
||||
auth,
|
||||
outbound_initialized,
|
||||
outbound_experimental_api_enabled,
|
||||
outbound_opted_out_notification_methods,
|
||||
@@ -1149,12 +1151,15 @@ pub async fn run_main_with_transport_options(
|
||||
}
|
||||
}
|
||||
TransportEvent::IncomingMessage { connection_id, message } => {
|
||||
let Some(connection_state) = connections.get_mut(&connection_id) else {
|
||||
warn!("dropping message from unknown connection: {connection_id:?}");
|
||||
continue;
|
||||
};
|
||||
if connection_state.session.rpc_gate.is_closed() {
|
||||
continue;
|
||||
}
|
||||
match message {
|
||||
JSONRPCMessage::Request(request) => {
|
||||
let Some(connection_state) = connections.get_mut(&connection_id) else {
|
||||
warn!("dropping request from unknown connection: {connection_id:?}");
|
||||
continue;
|
||||
};
|
||||
let was_initialized =
|
||||
connection_state.session.initialized();
|
||||
processor
|
||||
@@ -1216,24 +1221,12 @@ pub async fn run_main_with_transport_options(
|
||||
}
|
||||
}
|
||||
JSONRPCMessage::Response(response) => {
|
||||
if !connections.contains_key(&connection_id) {
|
||||
warn!("dropping response from unknown connection: {connection_id:?}");
|
||||
continue;
|
||||
}
|
||||
processor.process_response(connection_id, response).await;
|
||||
}
|
||||
JSONRPCMessage::Notification(notification) => {
|
||||
if !connections.contains_key(&connection_id) {
|
||||
warn!("dropping notification from unknown connection: {connection_id:?}");
|
||||
continue;
|
||||
}
|
||||
processor.process_notification(notification).await;
|
||||
}
|
||||
JSONRPCMessage::Error(err) => {
|
||||
if !connections.contains_key(&connection_id) {
|
||||
warn!("dropping error from unknown connection: {connection_id:?}");
|
||||
continue;
|
||||
}
|
||||
processor.process_error(connection_id, err).await;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user