feat(security): harden gateway boundaries and usage policies

Consolidate subscription usage policy enforcement, privacy-safe persistence, and gateway security hardening into one reviewable change.

Includes bounded HTTP and execution envelopes, header and protocol guards, DNS and relay validation, authentication and secret projection hardening, secure backup/install paths, and regression coverage.
This commit is contained in:
elky
2026-09-04 03:45:52 +08:00
parent ddcbeb3ae9
commit 579f2c7cc1
1019 changed files with 190437 additions and 26080 deletions
@@ -13,12 +13,8 @@ use aether_oauth::provider::{
use axum::{body::Body, http, response::Response};
use std::sync::Arc;
fn provider_oauth_transport_error_detail(prefix: &str, error: &str) -> String {
let error = error.trim();
if error.is_empty() {
return prefix.to_string();
}
format!("{prefix}: {error}")
fn provider_oauth_transport_error_detail(prefix: &str, _error: &str) -> String {
prefix.to_string()
}
fn provider_oauth_exchange_context(
@@ -182,3 +178,20 @@ pub(crate) async fn authorize_admin_provider_oauth_with_cookie(
)
})
}
#[cfg(test)]
mod tests {
use super::provider_oauth_transport_error_detail;
#[test]
fn provider_oauth_transport_error_does_not_reflect_network_details() {
let detail = provider_oauth_transport_error_detail(
"token exchange 失败",
"request failed for https://user:[email protected]/token?secret=value authorization=Bearer upstream-secret",
);
assert_eq!(detail, "token exchange 失败");
assert!(!detail.contains("upstream-secret"));
assert!(!detail.contains("user:pass"));
}
}