pub struct JwtClient { /* private fields */ }
Expand description
Service to manage JWT tokens
Implementations§
Source§impl JwtClient
impl JwtClient
Sourcepub fn encode_token(&self, user_id: Uuid) -> Result<String, AuthenticationError>
pub fn encode_token(&self, user_id: Uuid) -> Result<String, AuthenticationError>
Encode a JWT token for the given user
Sourcepub fn encode_token_with_exp(
&self,
user_id: Uuid,
exp_offset: i64,
) -> Result<String, Error>
pub fn encode_token_with_exp( &self, user_id: Uuid, exp_offset: i64, ) -> Result<String, Error>
Encode a JWT token with a custom expiration time
Sourcepub fn decode_token(&self, token: &str) -> Result<Claims, Error>
pub fn decode_token(&self, token: &str) -> Result<Claims, Error>
Decode a JWT token and provide its claims if it is valid
Sourcepub async fn user_or_403(
&self,
request: HttpRequest,
) -> Result<User, ApplicationError>
pub async fn user_or_403( &self, request: HttpRequest, ) -> Result<User, ApplicationError>
Given an incoming HTTP request, return the user currently logged in. If there is no
user logged in, generate a 403 Unauthorized
error response.
Auto Trait Implementations§
impl Freeze for JwtClient
impl !RefUnwindSafe for JwtClient
impl Send for JwtClient
impl Sync for JwtClient
impl Unpin for JwtClient
impl !UnwindSafe for JwtClient
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T
in a tonic::Request