Struct torrust_index_backend::web::api::v1::auth::Authentication
source · 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 !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