mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-11 11:49:50 +08:00
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:
@@ -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"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user