#[non_exhaustive]pub enum TargetPolicy {
PublicOnly,
AllowLocal,
}Expand description
Which hosts a resolution may reach, and over what scheme.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
PublicOnly
Public unicast addresses over HTTPS.
AllowLocal
Also permits loopback, private and link-local addresses, and plaintext
HTTP for localhost. Needed to resolve against a local server.
Whenever the DID being resolved is attacker-controlled, this is an SSRF
vector.
Implementations§
Source§impl TargetPolicy
impl TargetPolicy
Sourcepub const fn permits_address(self, ip: IpAddr) -> bool
pub const fn permits_address(self, ip: IpAddr) -> bool
Whether an address may be connected to.
Sourcepub fn permits_url(self, url: &Url) -> Result<(), TargetNotAllowed>
pub fn permits_url(self, url: &Url) -> Result<(), TargetNotAllowed>
Whether the URL may be fetched, judging its scheme and, when its host is a literal address, that address.
A hostname is left alone, because resolving it here and then connecting
would be two independent lookups that a hostile resolver can answer
differently. Judge those with Self::permits_address once, on the
address actually connected to.
§Errors
Returns TargetNotAllowed if the scheme or the literal host is
refused.
Sourcepub fn scheme_for(self, domain: &str) -> &'static str
pub fn scheme_for(self, domain: &str) -> &'static str
The scheme a did:web domain is fetched over. Plaintext HTTP is for a
localhost development server, which rarely has a certificate.
domain is the DID’s domain component, which may carry a port.
Trait Implementations§
Source§impl Clone for TargetPolicy
impl Clone for TargetPolicy
impl Copy for TargetPolicy
Source§impl Debug for TargetPolicy
impl Debug for TargetPolicy
Source§impl Default for TargetPolicy
impl Default for TargetPolicy
impl Eq for TargetPolicy
Source§impl PartialEq for TargetPolicy
impl PartialEq for TargetPolicy
impl StructuralPartialEq for TargetPolicy
Auto Trait Implementations§
impl Freeze for TargetPolicy
impl RefUnwindSafe for TargetPolicy
impl Send for TargetPolicy
impl Sync for TargetPolicy
impl Unpin for TargetPolicy
impl UnsafeUnpin for TargetPolicy
impl UnwindSafe for TargetPolicy
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.