Available on crate feature
security only.Expand description
Security utilities for safe logging and credential obfuscation.
Prevent accidental credential leaks in logs:
§Example
ⓘ
use allframe::security::{obfuscate_url, Sensitive};
let url = "https://user:password@api.example.com/v1/users";
println!("Connecting to: {}", obfuscate_url(url));
// Output: "Connecting to: https://api.example.com"
let api_key = Sensitive::new("sk_live_abcd1234");
println!("Using key: {:?}", api_key);
// Output: "Using key: ***"Security utilities for safe logging and data handling.
This module provides utilities for:
- Obfuscation: Safe logging of sensitive data (URLs, API keys, headers)
§Example
ⓘ
use allframe_core::security::{obfuscate_url, obfuscate_api_key};
let url = "https://user:password@api.example.com/v1/data?key=secret";
println!("Connecting to: {}", obfuscate_url(url));
// Output: "Connecting to: https://api.example.com/***"
let key = "sk_live_abcdefghijklmnop";
println!("Using key: {}", obfuscate_api_key(key));
// Output: "Using key: sk_l***mnop"Structs§
- Sensitive
- Helper struct for wrapping sensitive values.
Traits§
- Obfuscate
- Trait for types that can be obfuscated for safe logging.
Functions§
- obfuscate_
api_ key - Obfuscate an API key, showing only prefix and suffix.
- obfuscate_
header - Obfuscate a header value based on the header name.
- obfuscate_
redis_ url - Obfuscate a Redis URL, preserving host and port but hiding authentication.
- obfuscate_
url - Obfuscate a URL by removing credentials, path, and query parameters.