pub struct JwtAuth { /* private fields */ }
Expand description
JWT validating middleware for Actix-Web.
Implementations§
Source§impl JwtAuth
impl JwtAuth
Sourcepub fn new_from_env(
validator: fn(&ServiceRequest, &Option<Jwt>) -> bool,
) -> Result<Self, JwtAuthError>
pub fn new_from_env( validator: fn(&ServiceRequest, &Option<Jwt>) -> bool, ) -> Result<Self, JwtAuthError>
Create a new instance of JwtAuth. The URL for the keystore must be
provided in the environment variable JWKS_URL
at runtime.
A validator function of type JwtValidator
must be provided. For every
request, this will be called with the request and token information, and
the function will determine whether the request should be processed
(true
) or not (false
).
Sourcepub fn new_from_url(
validator: fn(&ServiceRequest, &Option<Jwt>) -> bool,
jwks_url: String,
) -> Result<Self, JwtAuthError>
pub fn new_from_url( validator: fn(&ServiceRequest, &Option<Jwt>) -> bool, jwks_url: String, ) -> Result<Self, JwtAuthError>
Create a new instance of JwtAuth. The keystore for validating token
signatures will be downloaded from the given jwks_url
.
A validator function of type JwtValidator
must be provided. For every
request, this will be called with the request and token information, and
the function will determine whether the request should be processed
(true
) or not (false
).
Trait Implementations§
Source§impl<S, B> Transform<S, ServiceRequest> for JwtAuthwhere
S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
B: MessageBody + 'static,
S::Future: 'static,
impl<S, B> Transform<S, ServiceRequest> for JwtAuthwhere
S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
B: MessageBody + 'static,
S::Future: 'static,
Source§type Transform = JwtAuthService<S>
type Transform = JwtAuthService<S>
TransformService
value created by this factorySource§type Future = Ready<Result<<JwtAuth as Transform<S, ServiceRequest>>::Transform, <JwtAuth as Transform<S, ServiceRequest>>::InitError>>
type Future = Ready<Result<<JwtAuth as Transform<S, ServiceRequest>>::Transform, <JwtAuth as Transform<S, ServiceRequest>>::InitError>>
Source§fn new_transform(&self, service: S) -> Self::Future
fn new_transform(&self, service: S) -> Self::Future
Auto Trait Implementations§
impl Freeze for JwtAuth
impl RefUnwindSafe for JwtAuth
impl !Send for JwtAuth
impl !Sync for JwtAuth
impl Unpin for JwtAuth
impl UnwindSafe for JwtAuth
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> 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