pub struct JwtManager { /* private fields */ }Expand description
JWT token manager
Implementations§
Source§impl JwtManager
impl JwtManager
Sourcepub fn generate_token(&self, user: &User) -> Result<String>
pub fn generate_token(&self, user: &User) -> Result<String>
Generate a JWT token for a user
Sourcepub fn generate_token_with_claims(&self, claims: &Claims) -> Result<String>
pub fn generate_token_with_claims(&self, claims: &Claims) -> Result<String>
Generate a token with custom claims
Sourcepub fn validate_token(&self, token: &str) -> Result<TokenValidation>
pub fn validate_token(&self, token: &str) -> Result<TokenValidation>
Validate a JWT token and return user information
Sourcepub fn validate_token_claims(&self, token: &str) -> Result<Claims>
pub fn validate_token_claims(&self, token: &str) -> Result<Claims>
Validate token and return full claims
Sourcepub fn get_token_id(&self, token: &str) -> Result<Option<String>>
pub fn get_token_id(&self, token: &str) -> Result<Option<String>>
Get JWT ID (jti) from token without full validation
Sourcepub fn extract_token_from_header(auth_header: &str) -> Option<&str>
pub fn extract_token_from_header(auth_header: &str) -> Option<&str>
Extract token from authorization header
Sourcepub fn generate_refresh_token(&self, user: &User) -> Result<String>
pub fn generate_refresh_token(&self, user: &User) -> Result<String>
Generate a refresh token
Sourcepub fn validate_refresh_token(&self, token: &str) -> Result<TokenValidation>
pub fn validate_refresh_token(&self, token: &str) -> Result<TokenValidation>
Validate a refresh token
Sourcepub fn get_token_expiration(&self, token: &str) -> Result<DateTime<Utc>>
pub fn get_token_expiration(&self, token: &str) -> Result<DateTime<Utc>>
Get token expiration time
Sourcepub fn is_token_close_to_expiration(&self, token: &str) -> Result<bool>
pub fn is_token_close_to_expiration(&self, token: &str) -> Result<bool>
Check if token is close to expiration (within 1 hour)
Auto Trait Implementations§
impl Freeze for JwtManager
impl RefUnwindSafe for JwtManager
impl Send for JwtManager
impl Sync for JwtManager
impl Unpin for JwtManager
impl UnwindSafe for JwtManager
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