pub struct ReverseProxyAuthenticator { /* private fields */ }Expand description
Authenticator that reads the caller’s identity from a header set by a
trusted upstream reverse proxy (e.g. nginx / Envoy / an OAuth2 proxy that
forwards X-Forwarded-User).
The proxy is responsible for actually authenticating the request; this
authenticator only trusts and extracts the forwarded identity, so it must
only be enabled when the server is not directly reachable — otherwise a
client could forge the header. It exists so that features which vend
credentials on the caller’s behalf (notably the same-origin storage
byte-proxy) attribute access to a real user instead of the over-privileged
Principal::anonymous.
When the header is absent, on_missing decides
whether to reject the request (401) or fall back to anonymous.
Implementations§
Source§impl ReverseProxyAuthenticator
impl ReverseProxyAuthenticator
Sourcepub fn new() -> Self
pub fn new() -> Self
Build an authenticator reading DEFAULT_FORWARDED_USER_HEADER,
rejecting requests that lack it.
Sourcepub fn with_header(self, header: impl Into<String>) -> Self
pub fn with_header(self, header: impl Into<String>) -> Self
Override the header the identity is read from.
Sourcepub fn with_on_missing(self, on_missing: OnMissingIdentity) -> Self
pub fn with_on_missing(self, on_missing: OnMissingIdentity) -> Self
Set the behavior when the header is absent (default:
OnMissingIdentity::Reject).
Trait Implementations§
Source§impl Clone for ReverseProxyAuthenticator
impl Clone for ReverseProxyAuthenticator
Source§fn clone(&self) -> ReverseProxyAuthenticator
fn clone(&self) -> ReverseProxyAuthenticator
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for ReverseProxyAuthenticator
impl RefUnwindSafe for ReverseProxyAuthenticator
impl Send for ReverseProxyAuthenticator
impl Sync for ReverseProxyAuthenticator
impl Unpin for ReverseProxyAuthenticator
impl UnsafeUnpin for ReverseProxyAuthenticator
impl UnwindSafe for ReverseProxyAuthenticator
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more