pub struct SecurityPolicy {
pub require_tls: bool,
pub ssrf_protection: bool,
}Expand description
Security posture applied to outbound A2aClient requests.
Named fields eliminate the transposition hazard of a two-bool builder method
(with_security(true, false) vs. with_security(false, true) are easy to swap
by accident) and group the security boundary as one reviewable unit.
§Examples
use zeph_a2a::{A2aClient, SecurityPolicy};
// Recommended for production: reject HTTP and private/loopback targets. Pass the
// policy directly to `new` so it can never be silently inherited by omission.
let client = A2aClient::new(reqwest::Client::new(), SecurityPolicy::hardened());
// Partial policy via named fields — no ambiguity about which flag is which.
let tls_only = SecurityPolicy {
require_tls: true,
ssrf_protection: false,
};
let _ = client.with_security(tls_only);Fields§
§require_tls: boolReject any endpoint that does not start with https://, and build requests with
https_only(true) so a redirect cannot silently downgrade the connection to http://.
ssrf_protection: boolResolve the endpoint hostname via DNS, reject private/loopback/link-local ranges, and pin the validated address for the actual connection so it cannot be re-resolved to a different (attacker-controlled) address between the check and the connect.
Implementations§
Source§impl SecurityPolicy
impl SecurityPolicy
Sourcepub const fn hardened() -> Self
pub const fn hardened() -> Self
Both protections enabled. The recommended posture for production deployments that talk to untrusted or third-party A2A endpoints.
§Examples
use zeph_a2a::SecurityPolicy;
let policy = SecurityPolicy::hardened();
assert!(policy.require_tls);
assert!(policy.ssrf_protection);Sourcepub const fn permissive() -> Self
pub const fn permissive() -> Self
Both protections disabled. Suitable only for local development against
trusted, non-adversarial endpoints (e.g. http://localhost).
§Examples
use zeph_a2a::SecurityPolicy;
let policy = SecurityPolicy::permissive();
assert!(!policy.require_tls);
assert!(!policy.ssrf_protection);Trait Implementations§
Source§impl Clone for SecurityPolicy
impl Clone for SecurityPolicy
Source§fn clone(&self) -> SecurityPolicy
fn clone(&self) -> SecurityPolicy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more