aKode fase 2a: rimossi cloud tasks, chatgpt apply, responses-api-proxy, codex app, remote control, guardian decisions; realtime senza fallback OpenAI; doctor senza sonde OpenAI
This commit is contained in:
@@ -188,7 +188,8 @@ impl From<RuntimeAuthError> for AuthError {
|
||||
| RuntimeAuthError::Task(_)
|
||||
| RuntimeAuthError::KeyGeneration
|
||||
| RuntimeAuthError::Registration(
|
||||
RegistrationError::InvalidEndpoint
|
||||
RegistrationError::Disabled
|
||||
| RegistrationError::InvalidEndpoint
|
||||
| RegistrationError::InvalidRequest
|
||||
| RegistrationError::InvalidResponse,
|
||||
) => false,
|
||||
|
||||
@@ -32,7 +32,12 @@ impl RuntimeRegistrationClient {
|
||||
.parse::<std::net::IpAddr>()
|
||||
.is_ok_and(|ip| ip.is_loopback())
|
||||
});
|
||||
if !(url.scheme() == "https" || (url.scheme() == "http" && loopback))
|
||||
// aKode: runtime registration is an OpenAI service (auth.openai.com). Only loopback
|
||||
// endpoints (local test servers) are accepted, so this fork never registers remotely.
|
||||
if !loopback {
|
||||
return Err(RegistrationError::Disabled);
|
||||
}
|
||||
if !(url.scheme() == "https" || url.scheme() == "http")
|
||||
|| !url.username().is_empty()
|
||||
|| url.password().is_some()
|
||||
|| url.query().is_some()
|
||||
@@ -103,6 +108,8 @@ impl RuntimeRegistrationClient {
|
||||
/// Errors intentionally omit raw transport details and server messages, which can contain secrets.
|
||||
#[derive(Clone, Debug, thiserror::Error)]
|
||||
pub enum RegistrationError {
|
||||
#[error("runtime registration with OpenAI is disabled in this build")]
|
||||
Disabled,
|
||||
#[error(
|
||||
"runtime registration requires a secure endpoint without credentials or query parameters"
|
||||
)]
|
||||
|
||||
@@ -257,9 +257,8 @@ async fn registration_never_forwards_credentials_through_a_redirect() {
|
||||
#[test]
|
||||
fn registration_rejects_unsafe_endpoints() {
|
||||
for endpoint in [
|
||||
"http://auth.example.com/register",
|
||||
"https://user:secret@auth.example.com/register",
|
||||
"https://auth.example.com/register?token=secret",
|
||||
"http://user:secret@127.0.0.1/register",
|
||||
"http://127.0.0.1/register?token=secret",
|
||||
] {
|
||||
assert!(matches!(
|
||||
RuntimeRegistrationClient::new(
|
||||
@@ -270,3 +269,21 @@ fn registration_rejects_unsafe_endpoints() {
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn registration_is_disabled_for_remote_endpoints() {
|
||||
for endpoint in [
|
||||
crate::DEFAULT_REGISTRATION_URL,
|
||||
"https://auth.api.openai.org/agent/register",
|
||||
"http://auth.example.com/register",
|
||||
"https://auth.example.com/register",
|
||||
] {
|
||||
assert!(matches!(
|
||||
RuntimeRegistrationClient::new(
|
||||
HttpClientFactory::new(OutboundProxyPolicy::ReqwestDefault),
|
||||
endpoint.parse().unwrap(),
|
||||
),
|
||||
Err(RegistrationError::Disabled)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user