Rimossi i provider integrati OpenAI, Bedrock e GCP e ogni fallback a OpenAI (B)
Parte "sicurezza" della fase 3 di aKode (e39aae00), senza le funzioni di imeAI:
- via i provider integrati openai, amazon-bedrock, amazon-bedrock-runtime e gcp
(crate model-provider: moduli amazon_bedrock, gcp, chatgpt_base_url; login Bedrock;
onboarding Bedrock/GCP; richieste app-server di setup cloud);
- nessun URL predefinito verso api.openai.com / chatgpt.com: un provider senza
base_url non viene mai contattato; senza model_provider configurato exec e TUI
mostrano come scriverne uno in config.toml (NO_MODEL_PROVIDER_CONFIGURED_ERROR);
- via la skill openai-docs, la sample skill-installer (scaricava da github.com/openai/skills),
request_plugin_install, AppsInstructions, URL predefiniti di realtime e updater;
- test di sicurezza adattati (provider "mock" al posto di quello integrato), non cancellati.
Restano fuori da questo commit (categoria F/D/E, non portate): chiave per provider nel
portachiavi, modelli da /models, unione dei messaggi di sistema, crate web-tools e
SearXNG, header @@ in apply_patch, modello ausiliario, tool function per apply_patch.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1124,8 +1124,7 @@ enabled = true
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn debug_sandbox_honors_explicit_managed_permission_profile() -> anyhow::Result<()>
|
||||
{
|
||||
async fn debug_sandbox_honors_explicit_managed_permission_profile() -> anyhow::Result<()> {
|
||||
let codex_home = TempDir::new()?;
|
||||
|
||||
let config = load_debug_sandbox_config_with_codex_home(
|
||||
@@ -1159,17 +1158,14 @@ enabled = true
|
||||
);
|
||||
assert_eq!(
|
||||
config.config_layer_stack.requirements_toml(),
|
||||
&toml::from_str::<ConfigRequirementsToml>(
|
||||
MANAGED_PERMISSION_PROFILE_REQUIREMENTS,
|
||||
)?,
|
||||
&toml::from_str::<ConfigRequirementsToml>(MANAGED_PERMISSION_PROFILE_REQUIREMENTS,)?,
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn debug_sandbox_ignores_managed_permission_profiles_by_default()
|
||||
-> anyhow::Result<()> {
|
||||
async fn debug_sandbox_ignores_managed_permission_profiles_by_default() -> anyhow::Result<()> {
|
||||
let codex_home = TempDir::new()?;
|
||||
|
||||
let config = load_debug_sandbox_config_with_codex_home(
|
||||
|
||||
@@ -1116,8 +1116,7 @@ fn codex_path_entries() -> Vec<String> {
|
||||
|
||||
fn config_check(config: &Config) -> DoctorCheck {
|
||||
let mut details = Vec::new();
|
||||
details
|
||||
.push("configuration scope: invocation config, including managed policy".to_string());
|
||||
details.push("configuration scope: invocation config, including managed policy".to_string());
|
||||
details.push("active thread overrides: not inspected".to_string());
|
||||
details.push(format!("CODEX_HOME: {}", config.codex_home.display()));
|
||||
details.push(format!("cwd: {}", config.cwd.display()));
|
||||
@@ -1327,7 +1326,7 @@ fn provider_specific_auth_check(
|
||||
env_var_present: impl Fn(&str) -> bool,
|
||||
) -> Option<DoctorCheck> {
|
||||
details.push(format!(
|
||||
"model provider requires OpenAI auth: {requires_openai_auth}"
|
||||
"model provider uses the stored API key: {requires_openai_auth}"
|
||||
));
|
||||
if requires_openai_auth {
|
||||
return None;
|
||||
@@ -1367,7 +1366,7 @@ fn provider_specific_auth_check(
|
||||
"auth.credentials",
|
||||
"auth",
|
||||
CheckStatus::Ok,
|
||||
"OpenAI auth is not required for the active model provider",
|
||||
"the stored API key is not used by the active model provider",
|
||||
)
|
||||
.details(details),
|
||||
),
|
||||
@@ -1378,8 +1377,6 @@ fn stored_auth_mode(auth: &codex_login::AuthDotJson) -> &'static str {
|
||||
match stored_auth_mode_value(auth) {
|
||||
Some(AuthMode::ApiKey) => "api_key",
|
||||
Some(AuthMode::Headers) => "headers",
|
||||
Some(AuthMode::BedrockApiKey) => "bedrock_api_key",
|
||||
Some(AuthMode::BedrockAccessKeys) => "bedrock_access_keys",
|
||||
None => "unsupported",
|
||||
}
|
||||
}
|
||||
@@ -1389,11 +1386,7 @@ fn stored_auth_mode_value(auth: &AuthDotJson) -> Option<AuthMode> {
|
||||
if let Some(mode) = auth.auth_mode {
|
||||
return Some(mode);
|
||||
}
|
||||
if auth.bedrock_api_key.is_some() {
|
||||
Some(AuthMode::BedrockApiKey)
|
||||
} else if auth.bedrock_access_keys.is_some() {
|
||||
Some(AuthMode::BedrockAccessKeys)
|
||||
} else if auth.openai_api_key.is_some() {
|
||||
if auth.openai_api_key.is_some() {
|
||||
Some(AuthMode::ApiKey)
|
||||
} else {
|
||||
None
|
||||
@@ -1426,22 +1419,6 @@ fn stored_auth_issues(
|
||||
AuthMode::Headers => {
|
||||
issues.push("header auth cannot be loaded from auth storage");
|
||||
}
|
||||
AuthMode::BedrockApiKey => {
|
||||
if auth.bedrock_api_key.is_none() {
|
||||
issues.push("Bedrock API key auth is missing a Bedrock API key");
|
||||
}
|
||||
}
|
||||
AuthMode::BedrockAccessKeys => match auth.bedrock_access_keys.as_ref() {
|
||||
Some(access_keys) => {
|
||||
if access_keys.access_key_id.trim().is_empty() {
|
||||
issues.push("Bedrock access key auth is missing an access key ID");
|
||||
}
|
||||
if access_keys.secret_access_key.trim().is_empty() {
|
||||
issues.push("Bedrock access key auth is missing a secret access key");
|
||||
}
|
||||
}
|
||||
None => issues.push("Bedrock access key auth is missing AWS access keys"),
|
||||
},
|
||||
}
|
||||
issues
|
||||
}
|
||||
@@ -2493,8 +2470,6 @@ fn auth_mode_name(auth: &CodexAuth) -> &'static str {
|
||||
match auth.auth_mode() {
|
||||
AuthMode::ApiKey => "api_key",
|
||||
AuthMode::Headers => "headers",
|
||||
AuthMode::BedrockApiKey => "bedrock_api_key",
|
||||
AuthMode::BedrockAccessKeys => "bedrock_access_keys",
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2602,7 +2577,6 @@ fn provider_reachability_plan(config: &Config) -> ReachabilityPlan {
|
||||
&config.model_provider.name,
|
||||
config.model_provider.base_url.as_deref(),
|
||||
query_params.as_ref(),
|
||||
config.model_provider.is_amazon_bedrock(),
|
||||
);
|
||||
plan.http_client_factory = config.http_client_factory();
|
||||
plan
|
||||
@@ -2616,7 +2590,6 @@ fn default_reachability_plan() -> ReachabilityPlan {
|
||||
"unknown",
|
||||
/*provider_base_url*/ None,
|
||||
/*provider_query_params*/ None,
|
||||
/*is_amazon_bedrock*/ false,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -2638,9 +2611,7 @@ fn provider_auth_reachability_mode_from_auth(
|
||||
return ProviderAuthReachabilityMode::ApiKey;
|
||||
}
|
||||
match stored_auth.and_then(stored_auth_mode_value) {
|
||||
Some(AuthMode::ApiKey | AuthMode::BedrockApiKey | AuthMode::BedrockAccessKeys) => {
|
||||
ProviderAuthReachabilityMode::ApiKey
|
||||
}
|
||||
Some(AuthMode::ApiKey) => ProviderAuthReachabilityMode::ApiKey,
|
||||
Some(AuthMode::Headers) | None => ProviderAuthReachabilityMode::NotRequired,
|
||||
}
|
||||
}
|
||||
@@ -2651,7 +2622,6 @@ fn provider_reachability_plan_from_parts(
|
||||
provider_name: &str,
|
||||
provider_base_url: Option<&str>,
|
||||
provider_query_params: Option<&HashMap<String, String>>,
|
||||
is_amazon_bedrock: bool,
|
||||
) -> ReachabilityPlan {
|
||||
// aKode: only an explicitly configured base URL outside OpenAI/ChatGPT is probed. The
|
||||
// implicit chatgpt.com and api.openai.com endpoints are never contacted.
|
||||
@@ -2661,7 +2631,7 @@ fn provider_reachability_plan_from_parts(
|
||||
label: format!("{provider_id} API"),
|
||||
url: provider_url_for_path(base_url, "responses", provider_query_params),
|
||||
required: true,
|
||||
route_probe_url: should_probe_models_route(provider_name, base_url, is_amazon_bedrock)
|
||||
route_probe_url: should_probe_models_route(provider_name, base_url)
|
||||
.then(|| provider_url_for_path(base_url, "models", provider_query_params)),
|
||||
})
|
||||
.into_iter()
|
||||
@@ -2673,8 +2643,8 @@ fn provider_reachability_plan_from_parts(
|
||||
}
|
||||
}
|
||||
|
||||
fn should_probe_models_route(provider_name: &str, base_url: &str, is_amazon_bedrock: bool) -> bool {
|
||||
!is_amazon_bedrock && !is_azure_responses_provider(provider_name, Some(base_url))
|
||||
fn should_probe_models_route(provider_name: &str, base_url: &str) -> bool {
|
||||
!is_azure_responses_provider(provider_name, Some(base_url))
|
||||
}
|
||||
|
||||
fn provider_url_for_path(
|
||||
@@ -3656,7 +3626,7 @@ mod tests {
|
||||
assert_eq!(check.status, CheckStatus::Ok);
|
||||
assert_eq!(
|
||||
check.summary,
|
||||
"OpenAI auth is not required for the active model provider"
|
||||
"the stored API key is not used by the active model provider"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3687,8 +3657,6 @@ mod tests {
|
||||
let auth = AuthDotJson {
|
||||
auth_mode: Some(AuthMode::ApiKey),
|
||||
openai_api_key: None,
|
||||
bedrock_api_key: None,
|
||||
bedrock_access_keys: None,
|
||||
};
|
||||
|
||||
assert_eq!(
|
||||
@@ -3721,8 +3689,6 @@ mod tests {
|
||||
let api_key_auth = AuthDotJson {
|
||||
auth_mode: Some(AuthMode::ApiKey),
|
||||
openai_api_key: Some("sk-test".to_string()),
|
||||
bedrock_api_key: None,
|
||||
bedrock_access_keys: None,
|
||||
};
|
||||
|
||||
assert_eq!(
|
||||
@@ -3792,7 +3758,6 @@ mod tests {
|
||||
"azure",
|
||||
Some("https://example.openai.azure.com/openai/v1"),
|
||||
/*provider_query_params*/ None,
|
||||
/*is_amazon_bedrock*/ false,
|
||||
),
|
||||
ReachabilityPlan {
|
||||
description: "provider auth".to_string(),
|
||||
@@ -3822,7 +3787,6 @@ mod tests {
|
||||
"Custom",
|
||||
Some("https://example.com/openai/v1/"),
|
||||
Some(&query_params),
|
||||
/*is_amazon_bedrock*/ false,
|
||||
),
|
||||
ReachabilityPlan {
|
||||
description: description.to_string(),
|
||||
@@ -3844,20 +3808,6 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn provider_reachability_skips_route_probe_for_bedrock() {
|
||||
let plan = provider_reachability_plan_from_parts(
|
||||
ProviderAuthReachabilityMode::NotRequired,
|
||||
"amazon-bedrock",
|
||||
"Amazon Bedrock",
|
||||
Some("https://bedrock-runtime.us-east-1.amazonaws.com/openai/v1"),
|
||||
/*provider_query_params*/ None,
|
||||
/*is_amazon_bedrock*/ true,
|
||||
);
|
||||
|
||||
assert_eq!(plan.endpoints[0].route_probe_url, None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn provider_reachability_never_infers_openai_endpoints() {
|
||||
let plan = provider_reachability_plan_from_parts(
|
||||
@@ -3866,7 +3816,6 @@ mod tests {
|
||||
"OpenAI",
|
||||
/*provider_base_url*/ None,
|
||||
/*provider_query_params*/ None,
|
||||
/*is_amazon_bedrock*/ false,
|
||||
);
|
||||
assert_eq!(plan.endpoints, Vec::new());
|
||||
|
||||
@@ -3880,7 +3829,6 @@ mod tests {
|
||||
"OpenAI",
|
||||
Some(base_url),
|
||||
/*provider_query_params*/ None,
|
||||
/*is_amazon_bedrock*/ false,
|
||||
);
|
||||
assert_eq!(plan.endpoints, Vec::new(), "{base_url}");
|
||||
}
|
||||
@@ -3929,7 +3877,6 @@ mod tests {
|
||||
"OpenAI",
|
||||
Some(&format!("http://{addr}/xxxx")),
|
||||
/*provider_query_params*/ None,
|
||||
/*is_amazon_bedrock*/ false,
|
||||
);
|
||||
|
||||
let check = provider_reachability_check(plan).await;
|
||||
@@ -3969,7 +3916,6 @@ mod tests {
|
||||
"OpenAI",
|
||||
Some(&format!("http://{addr}/v1")),
|
||||
/*provider_query_params*/ None,
|
||||
/*is_amazon_bedrock*/ false,
|
||||
);
|
||||
|
||||
let check = provider_reachability_check(plan).await;
|
||||
|
||||
@@ -85,8 +85,7 @@ pub(super) fn check(config: Option<&Config>) -> DoctorCheck {
|
||||
{
|
||||
let request_url = config
|
||||
.and_then(|config| config.model_provider.base_url.as_deref())
|
||||
.or_else(|| config.map(|config| config.chatgpt_base_url.as_str()))
|
||||
.unwrap_or("https://chatgpt.com/backend-api/");
|
||||
.unwrap_or("http://localhost/");
|
||||
let configuration = match macos_system_proxy_configuration(request_url) {
|
||||
MacosSystemProxyConfiguration::Automatic => "automatic (PAC)",
|
||||
MacosSystemProxyConfiguration::Manual => "manual",
|
||||
|
||||
@@ -22,7 +22,6 @@ async fn provider_reachability_rejects_proxy_authentication_challenges() {
|
||||
"Local",
|
||||
Some(&format!("{}/v1", proxy.uri())),
|
||||
/*provider_query_params*/ None,
|
||||
/*is_amazon_bedrock*/ false,
|
||||
);
|
||||
|
||||
let check = provider_reachability_check(plan).await;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
pub mod local_config;
|
||||
pub(crate) mod debug_sandbox;
|
||||
mod exit_status;
|
||||
pub mod local_config;
|
||||
pub(crate) mod login;
|
||||
|
||||
use clap::Args;
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
//! support can request from users.
|
||||
|
||||
use codex_core::config::Config;
|
||||
use codex_core::config::edit::ConfigEdit;
|
||||
use codex_core::config::edit::ConfigEditsBuilder;
|
||||
use codex_login::login_with_api_key;
|
||||
use codex_protocol::auth::AuthMode;
|
||||
use codex_protocol::config_types::ForcedLoginMethod;
|
||||
@@ -210,14 +208,6 @@ pub async fn run_login_status(cli_config_overrides: CliConfigOverrides) -> ! {
|
||||
AuthMode::Headers => {
|
||||
unreachable!("header auth cannot be loaded from auth storage")
|
||||
}
|
||||
AuthMode::BedrockApiKey => {
|
||||
eprintln!("Logged in using Amazon Bedrock API key");
|
||||
std::process::exit(0);
|
||||
}
|
||||
AuthMode::BedrockAccessKeys => {
|
||||
eprintln!("Logged in using Amazon Bedrock AWS access keys");
|
||||
std::process::exit(0);
|
||||
}
|
||||
},
|
||||
Ok(None) => {
|
||||
eprintln!("Not logged in");
|
||||
@@ -244,25 +234,7 @@ pub async fn run_logout(cli_config_overrides: CliConfigOverrides) -> ! {
|
||||
}
|
||||
};
|
||||
|
||||
let cleared_bedrock_config =
|
||||
if let Some(paths) = ConfigEditsBuilder::bedrock_provider_config_paths_to_clear(&config) {
|
||||
let edits = paths
|
||||
.into_iter()
|
||||
.map(|segments| ConfigEdit::ClearPath { segments });
|
||||
if let Err(err) = ConfigEditsBuilder::for_config(&config)
|
||||
.with_edits(edits)
|
||||
.apply()
|
||||
.await
|
||||
{
|
||||
eprintln!("Error clearing Amazon Bedrock configuration after logout: {err}");
|
||||
std::process::exit(1);
|
||||
}
|
||||
true
|
||||
} else {
|
||||
false
|
||||
};
|
||||
|
||||
if logged_out || cleared_bedrock_config {
|
||||
if logged_out {
|
||||
eprintln!("Successfully logged out");
|
||||
} else {
|
||||
eprintln!("Not logged in");
|
||||
|
||||
@@ -487,7 +487,7 @@ struct LoginCommand {
|
||||
|
||||
#[arg(
|
||||
long = "with-api-key",
|
||||
help = "Read the API key from stdin (e.g. `printenv OPENAI_API_KEY | codex login --with-api-key`)"
|
||||
help = "Read the API key from stdin (e.g. `printenv MY_KEY | codex login --with-api-key`)"
|
||||
)]
|
||||
with_api_key: bool,
|
||||
|
||||
@@ -1515,7 +1515,7 @@ async fn dispatch_cli(
|
||||
None => {
|
||||
if login_cli.api_key.is_some() {
|
||||
eprintln!(
|
||||
"The --api-key flag is no longer supported. Pipe the key instead, e.g. `printenv OPENAI_API_KEY | codex login --with-api-key`."
|
||||
"The --api-key flag is no longer supported. Pipe the key instead, e.g. `printenv MY_KEY | codex login --with-api-key`."
|
||||
);
|
||||
std::process::exit(1);
|
||||
} else if login_cli.with_api_key {
|
||||
@@ -1523,7 +1523,7 @@ async fn dispatch_cli(
|
||||
run_login_with_api_key(login_cli.config_overrides, api_key).await;
|
||||
} else {
|
||||
eprintln!(
|
||||
"Only API key login is supported. Pipe the key on stdin, e.g. `printenv OPENAI_API_KEY | codex login --with-api-key`."
|
||||
"Only API key login is supported. Pipe the key on stdin, e.g. `printenv MY_KEY | codex login --with-api-key`."
|
||||
);
|
||||
std::process::exit(1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user