pub struct AllowedOrigin(/* private fields */);Expand description
HTTPS (or gated loopback) origin that passed the product SSRF allowlist.
Construct only via AllowedOrigin::parse / AllowedOrigin::parse_with.
Field is private so callers cannot assign an arbitrary host without
re-validation (TYPE-L-004 / ADR 0006).
Implementations§
Source§impl AllowedOrigin
impl AllowedOrigin
Sourcepub fn parse(raw: &str) -> AppResult<Self>
pub fn parse(raw: &str) -> AppResult<Self>
Parse and normalize an HTTP(S) origin with production allowlist
(allow_loopback = false).
For offline wiremock / loopback origins use Self::parse_with.
§Errors
Returns crate::error::ErrorKind::Config when the string is not a valid http/https URL
with a host (empty, bare path, unsupported scheme, or non-allowlisted host).
Sourcepub fn parse_with(raw: &str, allow_loopback: bool) -> AppResult<Self>
pub fn parse_with(raw: &str, allow_loopback: bool) -> AppResult<Self>
Parse and normalize an HTTP(S) origin (scheme + host, no path required).
Hosts must pass the product SSRF allowlist. When allow_loopback is true,
127.0.0.1 / localhost with http or https are accepted (CLI
--allow-loopback or XDG TOML allow_loopback = true — never env).
Arbitrary origins such as https://evil.example are always rejected.
§Errors
Returns crate::error::ErrorKind::Config when the string is not a valid http/https URL
with a host (empty, bare path, unsupported scheme, or non-allowlisted host).
Sourcepub fn crates_io_default() -> Self
pub fn crates_io_default() -> Self
Default crates.io API origin (valid by construction).
Sourcepub fn docs_rs_default() -> Self
pub fn docs_rs_default() -> Self
Default docs.rs origin (valid by construction).
Sourcepub fn stdlib_docs_default() -> Self
pub fn stdlib_docs_default() -> Self
Default stdlib docs origin on doc.rust-lang.org (valid by construction).
Sourcepub fn to_url(&self) -> AppResult<Url>
pub fn to_url(&self) -> AppResult<Url>
Re-parse this validated origin into a WHATWG Url (fail-closed).
Used by URL builders that need a typed base. The stored string was produced
by Self::parse (or a default constructor), so failure is treated as an
internal invariant break rather than user input (ADR 0008).
§Errors
Returns crate::error::ErrorKind::Internal if the stored origin is not a valid URL
(should not happen for values constructed via this type).
Trait Implementations§
Source§impl AsRef<str> for AllowedOrigin
impl AsRef<str> for AllowedOrigin
Source§impl Clone for AllowedOrigin
impl Clone for AllowedOrigin
Source§impl Debug for AllowedOrigin
impl Debug for AllowedOrigin
Source§impl<'de> Deserialize<'de> for AllowedOrigin
impl<'de> Deserialize<'de> for AllowedOrigin
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Source§impl Display for AllowedOrigin
impl Display for AllowedOrigin
impl Eq for AllowedOrigin
Source§impl Hash for AllowedOrigin
impl Hash for AllowedOrigin
Source§impl PartialEq for AllowedOrigin
impl PartialEq for AllowedOrigin
Source§impl Serialize for AllowedOrigin
impl Serialize for AllowedOrigin
impl StructuralPartialEq for AllowedOrigin
Auto Trait Implementations§
impl Freeze for AllowedOrigin
impl RefUnwindSafe for AllowedOrigin
impl Send for AllowedOrigin
impl Sync for AllowedOrigin
impl Unpin for AllowedOrigin
impl UnsafeUnpin for AllowedOrigin
impl UnwindSafe for AllowedOrigin
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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.