pub struct SsrfPolicy {
pub reject_ip_literals: bool,
pub allow_http: bool,
pub allow_loopback_resolved: bool,
}Expand description
SSRF policy applied to outbound HTTP requests.
Fields§
§reject_ip_literals: boolIf true, reject IP literals in the URL (forces DNS resolution).
allow_http: boolIf false, only https:// URLs are accepted. Default false.
allow_loopback_resolved: boolWhen true, permit IPv4 127.0.0.0/8 and IPv6 ::1 (loopback)
across Self::check_ip / Self::check_resolved_ip /
[Self::pin_resolved_ip]. All other forbidden ranges
(RFC 1918, link-local / IMDS, ULA, CGNAT, multicast, …) still
apply. Default false.
Intended for test harnesses that resolve did:web:localhost…
against a self-signed in-process HTTPS server bound to
127.0.0.1. Production callers MUST keep this false — opening
loopback turns the resolver into an SSRF vector against
process-internal listeners (RFC-ACDP-0008 §4.8).
Implementations§
Source§impl SsrfPolicy
impl SsrfPolicy
Sourcepub fn check_url(&self, url: &str) -> Result<(), AcdpError>
pub fn check_url(&self, url: &str) -> Result<(), AcdpError>
Validate a URL string (scheme + host) before issuing a request.
Back-compat wrapper over Self::classify_url: a rejection maps
to AcdpError::SchemaViolation with the same detail message
callers have always seen.
Sourcepub fn classify_url(&self, url: &str) -> Result<(), SsrfRejection>
pub fn classify_url(&self, url: &str) -> Result<(), SsrfRejection>
Validate a URL string, returning a stable SsrfRejection
(reason code + detail) on failure.
Checks scheme (HTTPS-only unless allow_http), IP-literal
rejection, per-IP range filtering for literal hosts, and hostname
length. Prefer this over Self::check_url when the caller needs
to branch on why the URL was rejected (e.g. a language binding
mapping to a typed exception).
Sourcepub fn check_resolved_ip(&self, ip: IpAddr) -> Result<(), AcdpError>
pub fn check_resolved_ip(&self, ip: IpAddr) -> Result<(), AcdpError>
Validate an already-resolved IpAddr — useful when DNS resolution
is performed externally and the caller wants to filter pre-connect.
Respects Self::allow_loopback_resolved.
Sourcepub fn check_ip(&self, ip: IpAddr) -> Result<(), AcdpError>
pub fn check_ip(&self, ip: IpAddr) -> Result<(), AcdpError>
Range filter for a single IpAddr, respecting the policy’s
Self::allow_loopback_resolved flag.
Back-compat wrapper over Self::classify_ip.
Sourcepub fn classify_ip(&self, ip: IpAddr) -> Result<(), SsrfRejection>
pub fn classify_ip(&self, ip: IpAddr) -> Result<(), SsrfRejection>
Range filter for a single IpAddr, returning a stable
SsrfRejection (reason code + detail) when the address falls in
a forbidden range. Respects Self::allow_loopback_resolved.
Per §7.5: a redirect is permitted only if it stays within the same fetch authority as the originating request — identical scheme, host, and effective port (RFC-ACDP-0008 §4.8: “host + port”).
Same-authority redirect check returning a stable SsrfRejection.
See Self::check_redirect_authority.
Sourcepub fn classify_redirect(
&self,
from_url: &str,
to_url: &str,
) -> Result<(), SsrfRejection>
pub fn classify_redirect( &self, from_url: &str, to_url: &str, ) -> Result<(), SsrfRejection>
String-in/string-in convenience over Self::classify_redirect_authority
for FFI callers that hold both endpoints as strings (no url::Url
on the boundary). Parses from_url as the origin authority, then
applies the same scheme + host + effective-port equality.
Trait Implementations§
Source§impl Clone for SsrfPolicy
impl Clone for SsrfPolicy
Source§fn clone(&self) -> SsrfPolicy
fn clone(&self) -> SsrfPolicy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more