mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-08 18:37:46 +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:
@@ -52,12 +52,16 @@ mod headers;
|
||||
mod hooks;
|
||||
mod image_capabilities;
|
||||
mod important_notification;
|
||||
mod internal_gateway_auth;
|
||||
mod local_auth_token;
|
||||
mod log_ids;
|
||||
mod maintenance;
|
||||
mod management_token_auth;
|
||||
pub(crate) mod middleware;
|
||||
mod model_fetch;
|
||||
mod oauth;
|
||||
mod orchestration;
|
||||
mod plan_usage_policy;
|
||||
mod privacy;
|
||||
mod process_metrics;
|
||||
mod provider_key_auth;
|
||||
@@ -95,6 +99,11 @@ pub(crate) use self::ai_serving::{
|
||||
AiExecutionDecision, AiExecutionPlanPayload, AiStreamAttempt, AiSyncAttempt,
|
||||
};
|
||||
pub use self::async_task::VideoTaskTruthSourceMode;
|
||||
pub use self::backup::{
|
||||
apply_restored_backup, restore_backup_json, BackupApplyError, BackupDecryptionKey,
|
||||
BackupRestoreError, BackupRestoreLimits, BackupRestoreScope, RestoredBackupJson,
|
||||
DEFAULT_BACKUP_MAX_ENCRYPTED_BYTES, DEFAULT_BACKUP_MAX_JSON_BYTES,
|
||||
};
|
||||
pub use self::data::GatewayDataConfig;
|
||||
pub(crate) use self::error::GatewayError;
|
||||
pub(crate) use self::execution_runtime::{
|
||||
@@ -125,6 +134,75 @@ pub use self::tunnel::{
|
||||
build_tunnel_runtime_router_with_state, tunnel_protocol, TunnelConnConfig,
|
||||
TunnelControlPlaneClient, TunnelRuntimeState,
|
||||
};
|
||||
#[cfg(feature = "testkit")]
|
||||
pub fn configure_test_tunnel_security(
|
||||
state: &mut AppState,
|
||||
node_id: &str,
|
||||
tunnel_generation: &str,
|
||||
key: &str,
|
||||
) {
|
||||
use aether_data::repository::proxy_nodes::{InMemoryProxyNodeRepository, StoredProxyNode};
|
||||
use std::sync::Arc;
|
||||
|
||||
let node = StoredProxyNode::new(
|
||||
node_id.to_string(),
|
||||
"test tunnel node".to_string(),
|
||||
"127.0.0.1".to_string(),
|
||||
0,
|
||||
false,
|
||||
"offline".to_string(),
|
||||
30,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
true,
|
||||
false,
|
||||
0,
|
||||
)
|
||||
.expect("test tunnel node should be valid")
|
||||
.with_runtime_fields(
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
Some(serde_json::json!({
|
||||
"tunnel_security": {"encryption_key": key}
|
||||
})),
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
)
|
||||
.with_tunnel_generation(tunnel_generation.to_string());
|
||||
let repository = Arc::new(InMemoryProxyNodeRepository::seed([node]));
|
||||
let data = self::data::GatewayDataState::with_proxy_node_repository_for_testkit(
|
||||
repository,
|
||||
aether_crypto::DEVELOPMENT_ENCRYPTION_KEY,
|
||||
);
|
||||
state.replace_data_state(Arc::new(data));
|
||||
}
|
||||
#[cfg(feature = "testkit")]
|
||||
pub fn configure_test_tunnel_runtime_auth(
|
||||
state: TunnelRuntimeState,
|
||||
node_id: &str,
|
||||
tunnel_generation: &str,
|
||||
raw_management_token: &str,
|
||||
) -> Result<TunnelRuntimeState, String> {
|
||||
use std::sync::Arc;
|
||||
|
||||
let data = self::data::GatewayDataState::with_tunnel_management_auth_for_testkit(
|
||||
node_id,
|
||||
tunnel_generation,
|
||||
raw_management_token,
|
||||
aether_crypto::DEVELOPMENT_ENCRYPTION_KEY,
|
||||
)
|
||||
.map_err(|error| format!("failed to configure tunnel harness authentication: {error}"))?;
|
||||
Ok(state.with_data(Arc::new(data)))
|
||||
}
|
||||
pub use self::usage::UsageRuntimeConfig;
|
||||
|
||||
use axum::http::header::{HeaderName, HeaderValue};
|
||||
|
||||
Reference in New Issue
Block a user