pub struct JwtManager { /* private fields */ }
Expand description
JWT token manager
Implementations§
Source§impl JwtManager
impl JwtManager
Sourcepub async fn generate_access_token(
&self,
subject: String,
roles: Vec<Role>,
key_id: Option<String>,
client_ip: Option<String>,
session_id: Option<String>,
scope: Vec<String>,
) -> Result<String, JwtError>
pub async fn generate_access_token( &self, subject: String, roles: Vec<Role>, key_id: Option<String>, client_ip: Option<String>, session_id: Option<String>, scope: Vec<String>, ) -> Result<String, JwtError>
Generate an access token
Sourcepub async fn generate_refresh_token(
&self,
subject: String,
key_id: Option<String>,
session_id: Option<String>,
) -> Result<String, JwtError>
pub async fn generate_refresh_token( &self, subject: String, key_id: Option<String>, session_id: Option<String>, ) -> Result<String, JwtError>
Generate a refresh token
Sourcepub async fn validate_token(
&self,
token: &str,
) -> Result<TokenData<TokenClaims>, JwtError>
pub async fn validate_token( &self, token: &str, ) -> Result<TokenData<TokenClaims>, JwtError>
Validate and decode a token
Sourcepub async fn token_to_auth_context(
&self,
token: &str,
) -> Result<AuthContext, JwtError>
pub async fn token_to_auth_context( &self, token: &str, ) -> Result<AuthContext, JwtError>
Extract auth context from a valid token
Sourcepub async fn refresh_access_token(
&self,
refresh_token: &str,
new_roles: Vec<Role>,
client_ip: Option<String>,
scope: Vec<String>,
) -> Result<String, JwtError>
pub async fn refresh_access_token( &self, refresh_token: &str, new_roles: Vec<Role>, client_ip: Option<String>, scope: Vec<String>, ) -> Result<String, JwtError>
Refresh an access token using a refresh token
Sourcepub async fn revoke_token(&self, token: &str) -> Result<(), JwtError>
pub async fn revoke_token(&self, token: &str) -> Result<(), JwtError>
Revoke a token by adding it to blacklist
Sourcepub async fn cleanup_blacklist(&self) -> usize
pub async fn cleanup_blacklist(&self) -> usize
Clean up expired tokens from blacklist
Sourcepub fn decode_token_info(&self, token: &str) -> Result<TokenClaims, JwtError>
pub fn decode_token_info(&self, token: &str) -> Result<TokenClaims, JwtError>
Get token info without validating signature (for debugging)
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