Struct torrust_index_backend::auth::AuthorizationService
source · pub struct AuthorizationService { /* private fields */ }
Implementations§
source§impl AuthorizationService
impl AuthorizationService
pub fn new( cfg: Arc<Configuration>, database: Arc<Box<dyn Database>> ) -> AuthorizationService
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_claims_from_request(
&self,
req: &HttpRequest
) -> Result<UserClaims, ServiceError>
pub async fn get_claims_from_request( &self, req: &HttpRequest ) -> Result<UserClaims, ServiceError>
Get Claims from Request
Errors
This function will return an ServiceError::TokenNotFound
if HeaderValue
is None
This function will pass through the ServiceError::TokenInvalid
if unable to verify the JWT.
sourcepub async fn get_user_compact_from_request(
&self,
req: &HttpRequest
) -> Result<UserCompact, ServiceError>
pub async fn get_user_compact_from_request( &self, req: &HttpRequest ) -> Result<UserCompact, ServiceError>
Get User (in compact form) from Request
Errors
This function will return an ServiceError::UserNotFound
if unable to get user from database.
Auto Trait Implementations§
impl !RefUnwindSafe for AuthorizationService
impl Send for AuthorizationService
impl Sync for AuthorizationService
impl Unpin for AuthorizationService
impl !UnwindSafe for AuthorizationService
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