Add external header auth for existing realtime calls (#62114)

## What changed

Add `RealtimeExistingCallAuth` to `RealtimeAttachmentOptions`, with model-provider authentication as the default. Embedding hosts can explicitly select `ExternalHeaders` for existing calls to use header-based credentials and the host's transport without adding model-provider headers or performing runtime agent registration.

Require an explicit, nonempty sideband URL and header-based authentication for this mode. Destination authorization remains the trusted host's responsibility, and application network policy still applies.

## Testing

Add integration coverage for external-header and model-provider authentication through event delivery, reconnect, and detach. Verify that model-provider credentials are excluded in external-header mode and that invalid authentication, missing URLs, and network policy denials reject the attachment before a WebSocket handshake.

GitOrigin-RevId: 2c915e1cf76a3563f58f751272db1ec50718d925
This commit is contained in:
Shuo
2026-11-17 22:00:20 +00:00
committed by copyberry
parent 39a7b53fa4
commit 8dcd56d0cb
6 changed files with 470 additions and 20 deletions
+15 -1
View File
@@ -226,7 +226,19 @@ pub struct ConversationStartParams {
pub voice: Option<Option<RealtimeVoice>>,
}
/// Controls when an in-process realtime attachment may establish a connection.
/// Authentication selected by the embedding host for an existing call.
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
pub enum RealtimeExistingCallAuth {
/// Use the model provider's authentication and runtime destination checks.
#[default]
ModelProvider,
/// Use the selected auth manager's external headers and the host's transport.
/// The trusted host must authorize the destination, call owner, and calling
/// workload before selecting this mode. Never derive it from a client URL.
ExternalHeaders,
}
/// Controls connection admission and authentication for an in-process attachment.
#[derive(Debug, Clone, Default)]
pub struct RealtimeAttachmentOptions {
/// Set the watch to `true` to cancel a pending connection.
@@ -234,6 +246,8 @@ pub struct RealtimeAttachmentOptions {
pub cancel: Option<watch::Receiver<bool>>,
/// Optional caller deadline for publishing the connection. Cleanup can finish later.
pub start_before: Option<SystemTime>,
/// Applies only to existing calls; external headers require an explicit host-selected URL.
pub existing_call_auth: RealtimeExistingCallAuth,
}
/// A caller-owned realtime sideband. Dropping either direction seals input and ends