pub trait SessionStore: Send + Sync {
// Required methods
fn record_session<'life0, 'async_trait>(
&'life0 self,
record: SessionRecord,
) -> Pin<Box<dyn Future<Output = Result<(), SessionStoreError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn is_valid<'life0, 'async_trait>(
&'life0 self,
jti: Uuid,
now_us: i64,
) -> Pin<Box<dyn Future<Output = Result<bool, SessionStoreError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn revoke<'life0, 'async_trait>(
&'life0 self,
jti: Uuid,
now_us: i64,
) -> Pin<Box<dyn Future<Output = Result<(), SessionStoreError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn revoke_all_for_actor<'life0, 'life1, 'async_trait>(
&'life0 self,
actor_id: &'life1 str,
now_us: i64,
) -> Pin<Box<dyn Future<Output = Result<usize, SessionStoreError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn prune_expired<'life0, 'async_trait>(
&'life0 self,
now_us: i64,
) -> Pin<Box<dyn Future<Output = Result<usize, SessionStoreError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
Server-side registry of issued JWTs.
Implementations:
- [
InMemorySessionStore] —Arc<Mutex<HashMap>>, ships in this crate behindtest-utilsand is also a viable single-node production option SqliteSessionStore— inarc-es-sqlite, durable- Future: Postgres, Redis
Required Methods§
Sourcefn record_session<'life0, 'async_trait>(
&'life0 self,
record: SessionRecord,
) -> Pin<Box<dyn Future<Output = Result<(), SessionStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn record_session<'life0, 'async_trait>(
&'life0 self,
record: SessionRecord,
) -> Pin<Box<dyn Future<Output = Result<(), SessionStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Record a freshly-minted token. Called by the login controller before it returns the token to the client; on failure, the controller must refuse to hand out the token.
Sourcefn is_valid<'life0, 'async_trait>(
&'life0 self,
jti: Uuid,
now_us: i64,
) -> Pin<Box<dyn Future<Output = Result<bool, SessionStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn is_valid<'life0, 'async_trait>(
&'life0 self,
jti: Uuid,
now_us: i64,
) -> Pin<Box<dyn Future<Output = Result<bool, SessionStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
True if the jti is recorded, not revoked, and not expired.
Returns Err(Sink) on store unavailability — middleware must fail closed.
Sourcefn revoke<'life0, 'async_trait>(
&'life0 self,
jti: Uuid,
now_us: i64,
) -> Pin<Box<dyn Future<Output = Result<(), SessionStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn revoke<'life0, 'async_trait>(
&'life0 self,
jti: Uuid,
now_us: i64,
) -> Pin<Box<dyn Future<Output = Result<(), SessionStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Mark the session revoked. Idempotent; revoking an unknown jti
returns Err(NotFound) so callers can distinguish “already gone”
from “double revoke” if they care.
Sourcefn revoke_all_for_actor<'life0, 'life1, 'async_trait>(
&'life0 self,
actor_id: &'life1 str,
now_us: i64,
) -> Pin<Box<dyn Future<Output = Result<usize, SessionStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn revoke_all_for_actor<'life0, 'life1, 'async_trait>(
&'life0 self,
actor_id: &'life1 str,
now_us: i64,
) -> Pin<Box<dyn Future<Output = Result<usize, SessionStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Bulk-revoke every active session for an actor (breach response). Returns the count of records affected.
Sourcefn prune_expired<'life0, 'async_trait>(
&'life0 self,
now_us: i64,
) -> Pin<Box<dyn Future<Output = Result<usize, SessionStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn prune_expired<'life0, 'async_trait>(
&'life0 self,
now_us: i64,
) -> Pin<Box<dyn Future<Output = Result<usize, SessionStoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Hard-delete records past their expires_at_us. Returns rows removed.
Implementations may run this on a schedule; callers may also invoke
it inline at startup.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".