pub struct Authentication { /* private fields */ }
Implementations§
Source§impl Authentication
impl Authentication
pub fn new(json_web_token: Arc<JsonWebToken>) -> Self
Sourcepub async fn sign_jwt(&self, user: UserCompact) -> String
pub async fn sign_jwt(&self, user: UserCompact) -> String
Create Json Web Token
Sourcepub async fn verify_jwt(&self, token: &str) -> Result<UserClaims, ServiceError>
pub async fn verify_jwt(&self, token: &str) -> Result<UserClaims, ServiceError>
Sourcepub async fn get_user_id_from_bearer_token(
&self,
maybe_token: &Option<BearerToken>,
) -> Result<UserId, ServiceError>
pub async fn get_user_id_from_bearer_token( &self, maybe_token: &Option<BearerToken>, ) -> Result<UserId, ServiceError>
Get logged-in user ID from bearer token
§Errors
This function will return an error if it can get claims from the request
Auto Trait Implementations§
impl Freeze for Authentication
impl !RefUnwindSafe for Authentication
impl Send for Authentication
impl Sync for Authentication
impl Unpin for Authentication
impl !UnwindSafe for Authentication
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
Mutably borrows from an owned value. Read more
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>
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