aKode fase 2b-2: rimosso login ChatGPT e tutti i sottosistemi solo-ChatGPT

- Login: resta solo chiave API (+ header, Bedrock). Rimossi OAuth/browser,
  device code, refresh/revoke su auth.openai.com, PAT, agent/workload identity,
  runtime agent instance, backend-client e openapi-models, workspace routing.
- Rimossi: generazione immagini (ext + skill imagegen), history notes, plugin
  remoti (catalogo, sync, share), cyber access program, daybreak, cloud config
  e requirements (config_server ora fail-closed), attestation, frozen cloud
  skills, EMA MCP auth, Codex Apps/connettori, ricerca ospitata, header/zstd/
  routing/cookie del backend Codex, fallback OPENAI_API_KEY del realtime.
- Messaggi d'errore senza link a chatgpt.com.
- Chiavi di config legacy accettate e ignorate; feature rimosse = Stage::Removed.
- Test: cancellati solo quelli del codice rimosso; test di sicurezza
  (sandbox estensioni, permessi, redazione, auth storage, requirements)
  adattati. Restano solo fallimenti d'ambiente (code-mode-host/V8, ~/.agents).
- Istruzioni di sistema invariate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
andrea.difonzo
2026-11-10 16:20:15 +01:00
parent 82347a58ed
commit 6089fbde91
1573 changed files with 10289 additions and 177679 deletions

View File

@@ -9,7 +9,6 @@ use std::task::Waker;
use codex_http_client::HttpClientFactory;
use codex_http_client::OutboundProxyPolicy;
use codex_login::auth::AgentIdentityAuthPolicy;
use codex_login::auth::BedrockApiKeyAuth;
use codex_model_provider_info::AwsAuthRefreshConfig;
use codex_model_provider_info::AwsCredentialExportConfig;
@@ -18,11 +17,9 @@ use codex_model_provider_info::WireApi;
use codex_model_provider_info::create_oss_provider_with_base_url;
use codex_models_manager::ModelsManagerConfig;
use codex_models_manager::manager::RefreshStrategy;
use codex_protocol::account::PlanType;
use codex_protocol::config_types::ModelProviderAuthInfo;
use codex_protocol::openai_models::ModelInfo;
use codex_protocol::openai_models::ModelsResponse;
use codex_protocol::protocol::SessionSource;
use codex_utils_redacted_string::RedactedString;
use pretty_assertions::assert_eq;
use serde_json::json;
@@ -35,7 +32,6 @@ use wiremock::matchers::path;
use super::*;
use crate::RemoteCompactionSupport;
use crate::auth::AgentIdentitySessionFallback;
use crate::shared_state::process_shared_state;
fn provider_info_with_command_auth() -> ModelProviderInfo {
@@ -121,20 +117,13 @@ fn bedrock_api_key_auth() -> CodexAuth {
}
#[tokio::test]
async fn scoped_auth_ignores_scope_for_non_openai_provider() {
async fn request_auth_adds_no_headers_for_non_openai_provider() {
let provider = create_model_provider(
create_oss_provider_with_base_url("http://localhost:11434/v1", WireApi::Responses),
/*auth_manager*/ None,
);
let auth = provider
.api_auth_for_scope(ProviderAuthScope {
agent_identity_policy: AgentIdentityAuthPolicy::JwtOnly,
session_source: SessionSource::Cli,
agent_identity_session_fallback: AgentIdentitySessionFallback::default(),
})
.await
.expect("auth should resolve");
let auth = provider.request_auth().await.expect("auth should resolve");
assert!(auth.auth.to_auth_headers().unwrap().is_empty());
}
@@ -216,12 +205,12 @@ fn configured_provider_uses_luna_for_approval_review_with_api_key_auth() {
}
#[test]
fn configured_provider_uses_default_approval_review_model_with_chatgpt_auth() {
fn configured_provider_uses_default_approval_review_model_with_header_auth() {
let provider = create_model_provider(
ModelProviderInfo::create_openai_provider(/*base_url*/ None),
Some(AuthManager::from_auth_for_testing(
CodexAuth::create_dummy_chatgpt_auth_for_testing(),
)),
Some(AuthManager::from_auth_for_testing(CodexAuth::Headers(
codex_login::AuthHeaders::new(http::HeaderMap::new()),
))),
);
assert_eq!(
@@ -268,7 +257,7 @@ async fn configured_provider_resolves_default_and_explicit_endpoints() {
);
assert_eq!(
provider
.request_provider_and_auth(/*scope*/ None)
.request_provider_and_auth()
.await
.unwrap()
.0
@@ -301,10 +290,7 @@ async fn configured_provider_resolves_default_and_explicit_endpoints() {
)
.unwrap();
auth.reload().await;
let (api_provider, resolved) = provider
.request_provider_and_auth(/*scope*/ None)
.await
.unwrap();
let (api_provider, resolved) = provider.request_provider_and_auth().await.unwrap();
assert_eq!(api_provider.base_url, expected_base_url);
let headers = resolved.auth.to_auth_headers().unwrap();
assert_eq!(
@@ -326,10 +312,7 @@ async fn configured_provider_resolves_default_and_explicit_endpoints() {
("commercial-key", "https://api.openai.com/v1", None),
] {
let reads_before = rotating_auth.0.load(Ordering::SeqCst);
let (api_provider, resolved) = provider
.request_provider_and_auth(/*scope*/ None)
.await
.unwrap();
let (api_provider, resolved) = provider.request_provider_and_auth().await.unwrap();
assert_eq!(rotating_auth.0.load(Ordering::SeqCst), reads_before + 1);
let headers = resolved.auth.to_auth_headers().unwrap();
let expected_authorization = format!("Bearer {api_key}");
@@ -663,21 +646,18 @@ fn openai_provider_returns_api_key_account_state() {
}
#[test]
fn openai_provider_returns_chatgpt_account_state_without_email() {
fn openai_provider_returns_no_account_state_for_header_auth() {
let provider = create_model_provider(
ModelProviderInfo::create_openai_provider(/*base_url*/ None),
Some(AuthManager::from_auth_for_testing(
CodexAuth::create_dummy_chatgpt_auth_for_testing(),
)),
Some(AuthManager::from_auth_for_testing(CodexAuth::Headers(
codex_login::AuthHeaders::new(http::HeaderMap::new()),
))),
);
assert_eq!(
provider.account_state(),
Ok(ProviderAccountState {
account: Some(ProviderAccount::Chatgpt {
email: None,
plan_type: PlanType::Unknown,
}),
account: None,
requires_openai_auth: true,
})
);
@@ -907,10 +887,7 @@ async fn configured_provider_models_manager_uses_provider_bearer_token() {
codex_login::default_client::RESIDENCY_HEADER_NAME.to_string(),
"us".into(),
)]));
for auth in [
None,
Some(CodexAuth::create_dummy_chatgpt_auth_for_testing()),
] {
for auth in [None, Some(CodexAuth::from_api_key("unused-login-key"))] {
// Disabled discovery must ignore the catalog cached by the enabled run.
for enabled in [true, false] {
let provider = create_model_provider(