Preserve bootstrap discovery across authentication changes (#49432)

## Why

Embedded app-server configuration discovery must remain available after login and workspace changes, while content access granted to the previous account must be revoked.

## What changed

Give `AuthRouteConfig` a separate application network policy and bind embedded bootstrap authentication to the effective application policy. Use that policy for account-owned content clients and invalidate it when the authenticated owner changes, preserving the local, endpoint-restricted bootstrap policy.

## Testing

Add a regression test covering bootstrap discovery across login, workspace changes, and sign-out; revocation of previous account clients and permits; and continued enforcement of bootstrap endpoint restrictions and local requirements.

GitOrigin-RevId: 083933e69508224f8232349ba3750c02329af06a
This commit is contained in:
cooper-oai
2026-09-30 01:44:14 +00:00
committed by copyberry
parent 2cc65cdd4c
commit d8f69ea8bc
4 changed files with 149 additions and 8 deletions
+2 -6
View File
@@ -2136,10 +2136,7 @@ fn default_agent_identity_authapi_base_url() -> Option<String> {
impl AuthManager {
/// Returns the application policy associated with this account owner.
pub fn application_network_policy(&self) -> codex_http_client::NetworkPolicy {
self.auth_route_config
.http_client_factory()
.network_policy()
.clone()
self.auth_route_config.application_network_policy().clone()
}
/// Creates content clients bound to the account currently owned by this manager.
@@ -2637,8 +2634,7 @@ impl AuthManager {
auth_changed_for_refresh && !same_owner(previous, new_auth.as_ref());
if owner_changed {
self.auth_route_config
.http_client_factory()
.network_policy()
.application_network_policy()
.invalidate();
}
if auth_changed_for_refresh {
+14
View File
@@ -1,4 +1,5 @@
use codex_http_client::HttpClientFactory;
use codex_http_client::NetworkPolicy;
/// Auth-layer adapter around client-owned proxy policy.
///
@@ -7,6 +8,7 @@ use codex_http_client::HttpClientFactory;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct AuthRouteConfig {
http_client_factory: HttpClientFactory,
application_network_policy: NetworkPolicy,
local_bootstrap_factory: Option<HttpClientFactory>,
}
@@ -14,11 +16,19 @@ impl AuthRouteConfig {
/// Adapts an application-resolved HTTP client factory for auth requests.
pub fn from_http_client_factory(http_client_factory: HttpClientFactory) -> Self {
Self {
application_network_policy: http_client_factory.network_policy().clone(),
http_client_factory,
local_bootstrap_factory: None,
}
}
/// Selects the account-owned policy revoked when the authenticated identity changes.
/// Bootstrap discovery can use separate local rules until this policy is loaded.
pub fn with_application_network_policy(mut self, policy: NetworkPolicy) -> Self {
self.application_network_policy = policy;
self
}
/// Installs the configuration owner's local-only policy for auth discovery.
/// Only auth-owned endpoint constructors can access this factory.
pub fn with_local_bootstrap_factory(mut self, factory: HttpClientFactory) -> Self {
@@ -43,4 +53,8 @@ impl AuthRouteConfig {
pub fn http_client_factory(&self) -> &HttpClientFactory {
&self.http_client_factory
}
pub(crate) fn application_network_policy(&self) -> &NetworkPolicy {
&self.application_network_policy
}
}