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

@@ -10,14 +10,6 @@ use toml::Value as TomlValue;
use super::stack::RequirementsCompositionError;
// Authentication requirements that cloud-managed layers cannot set.
const LOCAL_ONLY_AUTH_REQUIREMENTS: &[&str] = &[
"allowed_login_methods",
"allowed_chatgpt_workspaces",
"cli_auth_credentials_store",
"chatgpt_base_url",
];
#[derive(Clone, Debug)]
pub struct RequirementsLayerEntry {
pub(super) source: RequirementSource,
@@ -102,19 +94,6 @@ impl ComposableRequirementsLayer {
.map(|base_dir| AbsolutePathBufGuard::new(base_dir.as_path()));
let mut regular_toml = parse_layer_toml(&toml, &source)?;
if matches!(source, RequirementSource::EnterpriseManaged { .. })
&& regular_toml.get("config_server").is_some()
{
return Err(RequirementsCompositionError::Parse {
layer_source: source.clone(),
message: "config_server may only be configured in local managed requirements"
.into(),
});
}
// These fields can only be set locally; ignore them before validating cloud policy.
strip_cloud_auth_requirements(&source, &mut regular_toml);
// Provider fragments can be incomplete until all requirements layers
// are merged. Resolve explicit paths while their source base is still
// available, without deserializing complete auth command objects.
@@ -293,14 +272,6 @@ fn strip_special_fields(layer_toml: &mut TomlValue) {
remove_nested_field_and_prune_empty(layer_toml, &["auto_review", "required_on_models"]);
}
pub(crate) fn strip_cloud_auth_requirements(source: &RequirementSource, value: &mut TomlValue) {
if matches!(source, RequirementSource::EnterpriseManaged { .. }) {
for field in LOCAL_ONLY_AUTH_REQUIREMENTS {
remove_top_level_field(value, field);
}
}
}
fn remove_top_level_field(value: &mut TomlValue, key: &str) -> Option<TomlValue> {
value.as_table_mut()?.remove(key)
}

View File

@@ -6,6 +6,5 @@ mod rules;
mod stack;
pub use layer::RequirementsLayerEntry;
pub(crate) use layer::strip_cloud_auth_requirements;
pub use stack::compose_requirements;
pub use stack::compose_requirements_for_hostname;

View File

@@ -18,9 +18,9 @@ use tempfile::tempdir;
fn layer(id: &str, name: &str, contents: &str) -> RequirementsLayerEntry {
RequirementsLayerEntry::from_toml(
RequirementSource::EnterpriseManaged {
id: id.to_string(),
name: name.to_string(),
RequirementSource::MdmManagedPreferences {
domain: name.to_string(),
key: id.to_string(),
},
contents,
)
@@ -57,40 +57,6 @@ fn empty_layers_compose_to_none() {
assert_eq!(composed, None);
}
#[test]
fn cloud_auth_requirements_do_not_override_local_or_discard_other_policy() {
let local = RequirementsLayerEntry::from_toml(
RequirementSource::Unknown,
r#"allowed_login_methods = ["api"]
cli_auth_credentials_store = "keyring"
chatgpt_base_url = "https://managed.example/backend-api/""#,
);
for cloud_auth in [
r#"allowed_login_methods = ["api", "chatgpt"]
allowed_chatgpt_workspaces = ["other"]"#,
r#"allowed_login_methods = ["saml"]
allowed_chatgpt_workspaces = "invalid"
cli_auth_credentials_store = "invalid"
chatgpt_base_url = false"#,
] {
let cloud = layer(
"req_cloud",
"Cloud policy",
&format!("{cloud_auth}\nallow_login_shell = false"),
);
assert_eq!(
compose(vec![local.clone(), cloud])
.expect("cloud auth cannot invalidate enterprise policy"),
Some(expected_requirements(
r#"allowed_login_methods = ["api"]
cli_auth_credentials_store = "keyring"
chatgpt_base_url = "https://managed.example/backend-api/"
allow_login_shell = false"#
))
);
}
}
#[test]
fn top_level_values_use_toml_priority() {
let composed = compose(vec![
@@ -583,9 +549,9 @@ allow_managed_hooks_only = true
composed.allow_managed_hooks_only,
Some(Sourced::new(
/*value*/ true,
RequirementSource::EnterpriseManaged {
id: "req_1".to_string(),
name: "Security baseline".to_string(),
RequirementSource::MdmManagedPreferences {
domain: "Security baseline".to_string(),
key: "req_1".to_string(),
},
))
);
@@ -684,13 +650,13 @@ fn feature_aliases_merge_with_layer_precedence() {
#[test]
fn merged_table_source_is_composite_in_priority_order() {
let high_source = RequirementSource::EnterpriseManaged {
id: "req_high".to_string(),
name: "High".to_string(),
let high_source = RequirementSource::MdmManagedPreferences {
domain: "High".to_string(),
key: "req_high".to_string(),
};
let low_source = RequirementSource::EnterpriseManaged {
id: "req_low".to_string(),
name: "Low".to_string(),
let low_source = RequirementSource::MdmManagedPreferences {
domain: "Low".to_string(),
key: "req_low".to_string(),
};
let composed = compose_requirements_for_hostname(
vec![
@@ -1337,8 +1303,8 @@ managed_dir = "/managed/high"
)
.expect_err("conflicting managed dirs should fail closed");
assert!(err.to_string().contains("hooks.managed_dir"));
assert!(err.to_string().contains("High (req_high)"));
assert!(err.to_string().contains("Low (req_low)"));
assert!(err.to_string().contains("MDM High:req_high"));
assert!(err.to_string().contains("MDM Low:req_low"));
}
#[test]
@@ -1367,8 +1333,8 @@ windows_managed_dir = 'C:\managed\high'
.expect_err("conflicting windows managed dirs should fail closed");
assert!(err.to_string().contains("hooks.windows_managed_dir"));
assert!(err.to_string().contains("High (req_high)"));
assert!(err.to_string().contains("Low (req_low)"));
assert!(err.to_string().contains("MDM High:req_high"));
assert!(err.to_string().contains("MDM Low:req_low"));
}
#[test]
@@ -1672,7 +1638,7 @@ fn parse_error_names_layer() {
)])
.expect_err("invalid layer should fail");
assert!(err.to_string().contains("Bad layer (req_bad)"));
assert!(err.to_string().contains("MDM Bad layer:req_bad"));
assert!(err.to_string().contains("allowed_approval_policies"));
}
@@ -1785,7 +1751,10 @@ reff = "main"
)])
.expect_err("invalid marketplace rule should fail");
assert!(err.to_string().contains("Bad marketplace layer (req_bad)"));
assert!(
err.to_string()
.contains("MDM Bad marketplace layer:req_bad")
);
assert!(err.to_string().contains("unknown field `reff`"));
}
@@ -1891,20 +1860,3 @@ scopes = ["policy.read"]
}
);
}
#[test]
fn fetched_policy_cannot_change_config_server() {
let result = crate::compose_requirements([RequirementsLayerEntry::from_toml(
RequirementSource::EnterpriseManaged {
id: "remote".into(),
name: "Remote policy".into(),
},
"[config_server]\nbase_url = 'https://replacement.example/settings'",
)]);
assert!(
result
.unwrap_err()
.to_string()
.contains("only be configured in local managed requirements")
);
}