mirror of
https://github.com/openai/codex.git
synced 2026-11-08 20:40:33 +00:00
Bind runtime auth to the provider's selected credential source (#59823)
## Why Runtime authentication must use the credential selected by the model provider. Explicit API keys and command credentials need independent ownership so cached connections and in-flight work cannot cross credential sources. ## What changed - Register and reuse runtimes per credential source, supporting explicit provider keys and command credentials without falling back to saved login credentials. - Track `AuthOwner` by credential manager and owner generation across WebSocket state, compaction, and scoring. - Preserve cached identity and runtime registration state during credential-source outages or failed storage reloads. Require a successful auth reload before logout revokes credentials. - Reject requests whose production or staging environment differs from runtime registration, including model catalog requests. ## Testing Add regression coverage for credential selection and runtime reuse, owner isolation, source outages, failed reloads and logout recovery, and environment mismatches. GitOrigin-RevId: 7bab55e0ea502593393df10046309fd8502edbd0
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
use crate::ActorInfo;
|
||||
use crate::RegistrationError;
|
||||
use crate::RuntimeAgentInstance;
|
||||
use crate::RuntimeAuthBinding;
|
||||
use crate::RuntimeAuthError;
|
||||
use codex_api::AuthError;
|
||||
use codex_api::AuthHeaderTelemetry;
|
||||
@@ -12,6 +13,7 @@ use codex_features::RuntimeAuthMode;
|
||||
use codex_http_client::CHATGPT_ACCOUNT_ID_HEADER;
|
||||
use codex_http_client::HttpClientFactory;
|
||||
use codex_login::AuthChangeState;
|
||||
use codex_login::AuthOwner;
|
||||
use codex_login::CodexAuth;
|
||||
use http::HeaderMap;
|
||||
use http::HeaderValue;
|
||||
@@ -28,6 +30,8 @@ pub struct RuntimeAuth {
|
||||
pub(crate) auth: CodexAuth,
|
||||
pub(crate) http_client_factory: HttpClientFactory,
|
||||
pub(crate) change_state: AuthChangeState,
|
||||
pub(crate) owner: AuthOwner,
|
||||
pub(crate) binding: Arc<RuntimeAuthBinding>,
|
||||
}
|
||||
|
||||
impl std::fmt::Debug for RuntimeAuth {
|
||||
@@ -63,6 +67,14 @@ impl RuntimeAuth {
|
||||
self.change_state
|
||||
}
|
||||
|
||||
pub fn auth_owner(&self) -> &AuthOwner {
|
||||
&self.owner
|
||||
}
|
||||
|
||||
pub fn binding(&self) -> &Arc<RuntimeAuthBinding> {
|
||||
&self.binding
|
||||
}
|
||||
|
||||
/// Preserve the caller's transport settings and restrictions while binding requests to
|
||||
/// this credential's account. Independent managed policies must not replace each other.
|
||||
pub fn bind_http_client_factory(
|
||||
|
||||
Reference in New Issue
Block a user