pub enum RedirectError {
EmptyUri,
ProtocolRelative,
BackslashInPath,
SchemeNotAllowed {
scheme: String,
},
HostNotAllowed {
host: String,
},
}Expand description
Why a redirect URI was rejected by the safe-by-default validators
(Redirect::to, Redirect::permanent, Redirect::temporary).
br-asupersync-0hj233: this enum surfaces the open-redirect defense
as an explicit error type so callers either (a) handle the error
(return 400 to the user) or (b) opt into the explicit
Redirect::external_unchecked escape hatch when they truly need
to redirect to an external host (OAuth callbacks, payment-gateway
hand-offs, etc.).
Variants§
EmptyUri
URI is empty.
ProtocolRelative
URI starts with // — protocol-relative, browser switches host
to whatever follows the slashes. Trivial open-redirect vector
that defeats naive starts_with("/") defenses.
BackslashInPath
URI contains a backslash (\). Some HTTP intermediaries and
browsers normalize \ → /, so /\\attacker.com/x becomes
//attacker.com/x — the protocol-relative attack via a
different parser quirk.
SchemeNotAllowed
URI has a scheme other than http or https (e.g.,
javascript:, data:, file:, ftp:). javascript: redirects
in Location headers were historically followed by some browsers
and remain a source of XSS.
HostNotAllowed
URI has an absolute http(s) URL but its host is not in the
caller-provided allowed_hosts allowlist.
Trait Implementations§
Source§impl Clone for RedirectError
impl Clone for RedirectError
Source§fn clone(&self) -> RedirectError
fn clone(&self) -> RedirectError
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RedirectError
impl Debug for RedirectError
Source§impl Display for RedirectError
impl Display for RedirectError
Source§impl Error for RedirectError
impl Error for RedirectError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl PartialEq for RedirectError
impl PartialEq for RedirectError
Source§fn eq(&self, other: &RedirectError) -> bool
fn eq(&self, other: &RedirectError) -> bool
self and other values to be equal, and is used by ==.impl Eq for RedirectError
impl StructuralPartialEq for RedirectError
Auto Trait Implementations§
impl Freeze for RedirectError
impl RefUnwindSafe for RedirectError
impl Send for RedirectError
impl Sync for RedirectError
impl Unpin for RedirectError
impl UnsafeUnpin for RedirectError
impl UnwindSafe for RedirectError
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§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.