pub struct TokenManager { /* private fields */ }Expand description
Manages JWT token generation and validation
Implementations§
Source§impl TokenManager
impl TokenManager
Sourcepub fn new(secret: &[u8], token_validity: Duration) -> Self
pub fn new(secret: &[u8], token_validity: Duration) -> Self
Create a new token manager with the given secret
Sourcepub fn generate_token(
&self,
subject: &str,
tunnel_id: Option<String>,
) -> Result<String, Error>
pub fn generate_token( &self, subject: &str, tunnel_id: Option<String>, ) -> Result<String, Error>
Generate a new JWT token
Sourcepub fn validate_token(&self, token: &str) -> Result<TunnelClaims, TokenError>
pub fn validate_token(&self, token: &str) -> Result<TunnelClaims, TokenError>
Validate a JWT token
Sourcepub fn revoke_token(&self, jti: &str)
pub fn revoke_token(&self, jti: &str)
Revoke a token by its ID
Sourcepub fn cleanup_revocations(&self, max_age: Duration)
pub fn cleanup_revocations(&self, max_age: Duration)
Clean up expired revocations (call periodically)
Auto Trait Implementations§
impl !RefUnwindSafe for TokenManager
impl Freeze for TokenManager
impl Send for TokenManager
impl Sync for TokenManager
impl Unpin for TokenManager
impl UnsafeUnpin for TokenManager
impl UnwindSafe for TokenManager
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