Expand description
The storage contract and the built-in stores.
The guard holds all security logic; a store only persists records and performs two
operations atomically: SessionStore::apply (rotate, mark used, update) and the lookups.
Implement SessionStore for your own backend and run the
store_conformance! (feature testing) suite against it.
Structs§
- Memory
Store - Keeps everything in memory behind one mutex. Nothing survives a restart and nothing is shared between processes, so use it for tests, development and single-instance apps only.
- PgStore
postgres - Stores sessions in PostgreSQL through a sqlx
PgPool. Shared safely by any number of processes; rotations are single transactions with a conditional update, and a partial unique index guarantees at most one current token per session. - Rotation
- Replace the current token with a new one.
- Session
Record - A stored session.
- Session
Update - Everything one request changes, applied atomically by
SessionStore::apply. - Token
Lookup - Result of
SessionStore::find_by_token. - Token
Record - A stored token.
- Valkey
Store valkey - A
SessionStoreon Valkey or Redis, standalone or Cluster.
Enums§
- Claim
Scope - What an event claim is deduplicated by. See
SessionStore::claim_event. - Supersede
- Which token a
Rotationreplaces. Each variant is a condition evaluated atomically against the session’s current token; if it does not hold, nothing rotates.
Traits§
- Session
Store - Session persistence.
Functions§
- session_
bucket - The bucket a session id belongs to: its last byte. Sharded stores keep all of a session’s records in this bucket, and the guard sets that byte when it creates the id.
- token_
bucket - The bucket a token belongs to: the first byte of its hash. A session’s tokens share its
session_bucketwhen the store is sharded.