Trait actix_jwt_session::TokenStorage
source · pub trait TokenStorage: Send + Sync {
// Required methods
fn get_by_jti<'life0, 'async_trait>(
self: Arc<Self>,
jti: &'life0 [u8]
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, Error>> + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn set_by_jti<'life0, 'life1, 'life2, 'async_trait>(
self: Arc<Self>,
jwt_jti: &'life0 [u8],
refresh_jti: &'life1 [u8],
bytes: &'life2 [u8],
exp: Duration
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn remove_by_jti<'life0, 'async_trait>(
self: Arc<Self>,
jti: &'life0 [u8]
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}
Expand description
Allows to customize where and how sessions are stored in persistant storage. By default redis can be used to store sesions but it’s possible and easy to use memcached or postgresql.
Required Methods§
sourcefn get_by_jti<'life0, 'async_trait>(
self: Arc<Self>,
jti: &'life0 [u8]
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, Error>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_by_jti<'life0, 'async_trait>(
self: Arc<Self>,
jti: &'life0 [u8]
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, Error>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Load claims from storage or returns Error if record does not exists or there was other error while trying to fetch data from storage.
sourcefn set_by_jti<'life0, 'life1, 'life2, 'async_trait>(
self: Arc<Self>,
jwt_jti: &'life0 [u8],
refresh_jti: &'life1 [u8],
bytes: &'life2 [u8],
exp: Duration
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn set_by_jti<'life0, 'life1, 'life2, 'async_trait>(
self: Arc<Self>,
jwt_jti: &'life0 [u8],
refresh_jti: &'life1 [u8],
bytes: &'life2 [u8],
exp: Duration
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Save claims in storage in a way claims can be loaded from database using jti
as uuid::Uuid (JWT ID)
sourcefn remove_by_jti<'life0, 'async_trait>(
self: Arc<Self>,
jti: &'life0 [u8]
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn remove_by_jti<'life0, 'async_trait>(
self: Arc<Self>,
jti: &'life0 [u8]
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Erase claims from storage. You may ignore if claims does not exists in storage. Redis implementation returns Error::NotFound if record does not exists.