Struct HttpAuthorizer
pub struct HttpAuthorizer<A, C> { /* private fields */ }
Expand description
Utility type to allow you to use any Authorizer
that works with Credentials
to authorize the Authorization
header,
and return StatusCode::UNAUTHORIZED
response with header::WWW_AUTHENTICATE
for unauthorized request,
tracing the original error for your convenience.
Implementations§
§impl<A, C> HttpAuthorizer<A, C>
impl<A, C> HttpAuthorizer<A, C>
pub fn new(authorizer: A) -> HttpAuthorizer<A, C>
pub fn with_allow_anonymous(self, allow: bool) -> HttpAuthorizer<A, C>
pub fn with_allow_anonymous(self, allow: bool) -> HttpAuthorizer<A, C>
Defines whether or not to allow anonymous.
This means that the request is will be authorized automatically,
if no Authorization
header was passed in.
pub fn set_allow_anonymous(&mut self, allow: bool) -> &mut HttpAuthorizer<A, C>
pub fn set_allow_anonymous(&mut self, allow: bool) -> &mut HttpAuthorizer<A, C>
Defines whether or not to allow anonymous.
This means that the request is will be authorized automatically,
if no Authorization
header was passed in.
Trait Implementations§
§impl<A, C> Authorizer<C> for HttpAuthorizer<A, C>
impl<A, C> Authorizer<C> for HttpAuthorizer<A, C>
§impl<A, C> Clone for HttpAuthorizer<A, C>where
A: Clone,
impl<A, C> Clone for HttpAuthorizer<A, C>where
A: Clone,
§fn clone(&self) -> HttpAuthorizer<A, C>
fn clone(&self) -> HttpAuthorizer<A, C>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read more§impl<A, C> Debug for HttpAuthorizer<A, C>where
A: Debug,
impl<A, C> Debug for HttpAuthorizer<A, C>where
A: Debug,
§impl<const N: usize, C> From<[C; N]> for HttpAuthorizer<[C; N], C>where
C: Credentials,
impl<const N: usize, C> From<[C; N]> for HttpAuthorizer<[C; N], C>where
C: Credentials,
§fn from(value: [C; N]) -> HttpAuthorizer<[C; N], C>
fn from(value: [C; N]) -> HttpAuthorizer<[C; N], C>
Converts to this type from the input type.
§impl From<Basic> for HttpAuthorizer<StaticAuthorizer<Basic>, Basic>
impl From<Basic> for HttpAuthorizer<StaticAuthorizer<Basic>, Basic>
§fn from(value: Basic) -> HttpAuthorizer<StaticAuthorizer<Basic>, Basic>
fn from(value: Basic) -> HttpAuthorizer<StaticAuthorizer<Basic>, Basic>
Converts to this type from the input type.
§impl From<Bearer> for HttpAuthorizer<StaticAuthorizer<Bearer>, Bearer>
impl From<Bearer> for HttpAuthorizer<StaticAuthorizer<Bearer>, Bearer>
§fn from(value: Bearer) -> HttpAuthorizer<StaticAuthorizer<Bearer>, Bearer>
fn from(value: Bearer) -> HttpAuthorizer<StaticAuthorizer<Bearer>, Bearer>
Converts to this type from the input type.
§impl<C> From<Vec<C>> for HttpAuthorizer<Vec<C>, C>where
C: Credentials,
impl<C> From<Vec<C>> for HttpAuthorizer<Vec<C>, C>where
C: Credentials,
§fn from(value: Vec<C>) -> HttpAuthorizer<Vec<C>, C>
fn from(value: Vec<C>) -> HttpAuthorizer<Vec<C>, C>
Converts to this type from the input type.
§impl<ReqBody, A, C> ValidateRequest<ReqBody> for HttpAuthorizer<A, C>where
ReqBody: Send + 'static,
A: Authorizer<C>,
<A as Authorizer<C>>::Error: Debug,
C: Credentials + Send + 'static,
impl<ReqBody, A, C> ValidateRequest<ReqBody> for HttpAuthorizer<A, C>where
ReqBody: Send + 'static,
A: Authorizer<C>,
<A as Authorizer<C>>::Error: Debug,
C: Credentials + Send + 'static,
§type ResponseBody = Body
type ResponseBody = Body
The body type used for responses to unvalidated requests.
§async fn validate(
&self,
ctx: Context,
request: Request<ReqBody>,
) -> Result<(Context, Request<ReqBody>), Response<<HttpAuthorizer<A, C> as ValidateRequest<ReqBody>>::ResponseBody>>
async fn validate( &self, ctx: Context, request: Request<ReqBody>, ) -> Result<(Context, Request<ReqBody>), Response<<HttpAuthorizer<A, C> as ValidateRequest<ReqBody>>::ResponseBody>>
Validate the request. Read more
Auto Trait Implementations§
impl<A, C> Freeze for HttpAuthorizer<A, C>where
A: Freeze,
impl<A, C> RefUnwindSafe for HttpAuthorizer<A, C>where
A: RefUnwindSafe,
impl<A, C> Send for HttpAuthorizer<A, C>where
A: Send,
impl<A, C> Sync for HttpAuthorizer<A, C>where
A: Sync,
impl<A, C> Unpin for HttpAuthorizer<A, C>where
A: Unpin,
impl<A, C> UnwindSafe for HttpAuthorizer<A, C>where
A: UnwindSafe,
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§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> ⓘ
Converts
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> ⓘ
Converts
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§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§fn and<P, B, E>(self, other: P) -> And<T, P>
fn and<P, B, E>(self, other: P) -> And<T, P>
Create a new
Policy
that returns Action::Follow
only if self
and other
return
Action::Follow
. Read more