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:
@@ -895,6 +895,44 @@ impl GatewayDataState {
|
||||
.await
|
||||
}
|
||||
|
||||
pub(crate) async fn compare_and_set_system_config_string_value(
|
||||
&self,
|
||||
key: &str,
|
||||
expected: &str,
|
||||
replacement: &str,
|
||||
) -> Result<bool, DataLayerError> {
|
||||
if let Some(values) = &self.system_config_values {
|
||||
let updated = {
|
||||
let mut values = values.write().expect("system config values lock");
|
||||
match values.get_mut(key) {
|
||||
Some(entry) if entry.value.as_str() == Some(expected) => {
|
||||
entry.value = serde_json::Value::String(replacement.to_string());
|
||||
entry.updated_at_unix_secs =
|
||||
Some(current_system_config_updated_at_unix_secs());
|
||||
true
|
||||
}
|
||||
_ => false,
|
||||
}
|
||||
};
|
||||
self.clear_cached_system_config_value(key);
|
||||
return Ok(updated);
|
||||
}
|
||||
|
||||
let result = match self.backends.as_ref() {
|
||||
Some(backends) => {
|
||||
crate::request_diagnostics::observe_db_operation(
|
||||
"system_config_compare_and_set",
|
||||
self.database_pool_summary(),
|
||||
backends.compare_and_set_system_config_string_value(key, expected, replacement),
|
||||
)
|
||||
.await
|
||||
}
|
||||
None => Ok(false),
|
||||
};
|
||||
self.clear_cached_system_config_value(key);
|
||||
result
|
||||
}
|
||||
|
||||
pub(crate) async fn upsert_system_config_value(
|
||||
&self,
|
||||
key: &str,
|
||||
|
||||
Reference in New Issue
Block a user