pub struct SessionData {
pub version: u8,
pub auth_state: AuthState,
pub fingerprint: Option<String>,
pub device_id: Option<DeviceId>,
pub custom: Value,
}Expand description
The complete session payload stored in the session store.
All authentication state is captured here in a flat, serializable form. Session data is serialized as JSON once per request, not per field access.
§Schema versioning
The version field is persisted with each session. When the library evolves
and SessionData gains or removes fields, bump SESSION_DATA_VERSION and
add a migration step in SessionData::migrate. The session layer calls
migrate automatically on load, so existing sessions are upgraded in-place
without requiring a coordinated session wipe.
Fields§
§version: u8Schema version of this session data. Used for forward-compatible deserialization: if a newer library version adds fields, older sessions are migrated transparently on load.
auth_state: AuthStateAuthentication state of the session principal.
fingerprint: Option<String>Fingerprint identifying the expected client for this session.
Set automatically by SessionBinding
when the session first becomes authenticated. Checked on every subsequent
request: a mismatch invalidates the session (possible hijacking).
device_id: Option<DeviceId>Opaque DeviceId resolved for the request that owns this session.
None when the device subsystem is disabled (the device feature is
off) or when the request was handled before the device resolver had
a chance to stamp it (the very first request on a brand-new browser,
before any Device row exists).
Independent of fingerprint: fingerprint is a
short-lived hijack guard recomputed on every request, whereas
device_id references a long-lived row in the device store that may
outlive any single session.
Carried ungated so the on-the-wire shape of SessionData does not
diverge across feature configurations. See
docs/identity/device.md.
custom: ValueEscape hatch for application-specific data stored alongside the session.
Implementations§
Source§impl SessionData
impl SessionData
Trait Implementations§
Source§impl Clone for SessionData
impl Clone for SessionData
Source§fn clone(&self) -> SessionData
fn clone(&self) -> SessionData
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SessionData
impl Debug for SessionData
Source§impl Default for SessionData
impl Default for SessionData
Source§impl<'de> Deserialize<'de> for SessionData
impl<'de> Deserialize<'de> for SessionData
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for SessionData
impl Serialize for SessionData
Source§impl Store<SessionId, SessionData> for MysqlSessionStore
Available on crate feature mysql only.
impl Store<SessionId, SessionData> for MysqlSessionStore
mysql only.Source§type Error = SqlStoreError
type Error = SqlStoreError
StoreError enum for
new backends; legacy wrappers may continue to surface
SqlStoreError / ValkeyStoreError / PostgresStoreError
until each is consolidated.Source§fn get(
&self,
key: &SessionId,
) -> impl Future<Output = Result<Option<SessionData>, Self::Error>> + Send
fn get( &self, key: &SessionId, ) -> impl Future<Output = Result<Option<SessionData>, Self::Error>> + Send
key. Ok(None) when the key is absent
(including TTL-expired); Err only on backend failure.Source§fn put(
&self,
key: &SessionId,
value: &SessionData,
ttl: Duration,
) -> impl Future<Output = Result<(), Self::Error>> + Send
fn put( &self, key: &SessionId, value: &SessionData, ttl: Duration, ) -> impl Future<Output = Result<(), Self::Error>> + Send
key with the given TTL.Source§fn delete(
&self,
key: &SessionId,
) -> impl Future<Output = Result<(), Self::Error>> + Send
fn delete( &self, key: &SessionId, ) -> impl Future<Output = Result<(), Self::Error>> + Send
key. Idempotent; does not error if absent.Source§fn prune_expired(&self) -> impl Future<Output = Result<u64, Self::Error>> + Send
fn prune_expired(&self) -> impl Future<Output = Result<u64, Self::Error>> + Send
Ok(0); backends owning their own
row table (SQLite, Postgres, in-memory) actually delete.Source§impl Store<SessionId, SessionData> for PostgresSessionStore
Available on crate feature postgres only.
impl Store<SessionId, SessionData> for PostgresSessionStore
postgres only.Source§type Error = SqlStoreError
type Error = SqlStoreError
StoreError enum for
new backends; legacy wrappers may continue to surface
SqlStoreError / ValkeyStoreError / PostgresStoreError
until each is consolidated.Source§fn get(
&self,
key: &SessionId,
) -> impl Future<Output = Result<Option<SessionData>, Self::Error>> + Send
fn get( &self, key: &SessionId, ) -> impl Future<Output = Result<Option<SessionData>, Self::Error>> + Send
key. Ok(None) when the key is absent
(including TTL-expired); Err only on backend failure.Source§fn put(
&self,
key: &SessionId,
value: &SessionData,
ttl: Duration,
) -> impl Future<Output = Result<(), Self::Error>> + Send
fn put( &self, key: &SessionId, value: &SessionData, ttl: Duration, ) -> impl Future<Output = Result<(), Self::Error>> + Send
key with the given TTL.Source§fn delete(
&self,
key: &SessionId,
) -> impl Future<Output = Result<(), Self::Error>> + Send
fn delete( &self, key: &SessionId, ) -> impl Future<Output = Result<(), Self::Error>> + Send
key. Idempotent; does not error if absent.Source§fn prune_expired(&self) -> impl Future<Output = Result<u64, Self::Error>> + Send
fn prune_expired(&self) -> impl Future<Output = Result<u64, Self::Error>> + Send
Ok(0); backends owning their own
row table (SQLite, Postgres, in-memory) actually delete.Source§impl Store<SessionId, SessionData> for SqliteSessionStore
Available on crate feature sqlite only.
impl Store<SessionId, SessionData> for SqliteSessionStore
sqlite only.Source§type Error = SqlStoreError
type Error = SqlStoreError
StoreError enum for
new backends; legacy wrappers may continue to surface
SqlStoreError / ValkeyStoreError / PostgresStoreError
until each is consolidated.Source§fn get(
&self,
key: &SessionId,
) -> impl Future<Output = Result<Option<SessionData>, Self::Error>> + Send
fn get( &self, key: &SessionId, ) -> impl Future<Output = Result<Option<SessionData>, Self::Error>> + Send
key. Ok(None) when the key is absent
(including TTL-expired); Err only on backend failure.Source§fn put(
&self,
key: &SessionId,
value: &SessionData,
ttl: Duration,
) -> impl Future<Output = Result<(), Self::Error>> + Send
fn put( &self, key: &SessionId, value: &SessionData, ttl: Duration, ) -> impl Future<Output = Result<(), Self::Error>> + Send
key with the given TTL.Source§fn delete(
&self,
key: &SessionId,
) -> impl Future<Output = Result<(), Self::Error>> + Send
fn delete( &self, key: &SessionId, ) -> impl Future<Output = Result<(), Self::Error>> + Send
key. Idempotent; does not error if absent.Source§fn prune_expired(&self) -> impl Future<Output = Result<u64, Self::Error>> + Send
fn prune_expired(&self) -> impl Future<Output = Result<u64, Self::Error>> + Send
Ok(0); backends owning their own
row table (SQLite, Postgres, in-memory) actually delete.Source§impl Store<SessionId, SessionData> for ValkeySessionStore
Available on crate feature valkey only.
impl Store<SessionId, SessionData> for ValkeySessionStore
valkey only.Source§type Error = ValkeyStoreError
type Error = ValkeyStoreError
StoreError enum for
new backends; legacy wrappers may continue to surface
SqlStoreError / ValkeyStoreError / PostgresStoreError
until each is consolidated.Source§fn get(
&self,
key: &SessionId,
) -> impl Future<Output = Result<Option<SessionData>, Self::Error>> + Send
fn get( &self, key: &SessionId, ) -> impl Future<Output = Result<Option<SessionData>, Self::Error>> + Send
key. Ok(None) when the key is absent
(including TTL-expired); Err only on backend failure.Source§fn put(
&self,
key: &SessionId,
value: &SessionData,
ttl: Duration,
) -> impl Future<Output = Result<(), Self::Error>> + Send
fn put( &self, key: &SessionId, value: &SessionData, ttl: Duration, ) -> impl Future<Output = Result<(), Self::Error>> + Send
key with the given TTL.Source§fn delete(
&self,
key: &SessionId,
) -> impl Future<Output = Result<(), Self::Error>> + Send
fn delete( &self, key: &SessionId, ) -> impl Future<Output = Result<(), Self::Error>> + Send
key. Idempotent; does not error if absent.Source§fn prune_expired(&self) -> impl Future<Output = Result<u64, Self::Error>> + Send
fn prune_expired(&self) -> impl Future<Output = Result<u64, Self::Error>> + Send
Ok(0); backends owning their own
row table (SQLite, Postgres, in-memory) actually delete.Auto Trait Implementations§
impl Freeze for SessionData
impl RefUnwindSafe for SessionData
impl Send for SessionData
impl Sync for SessionData
impl Unpin for SessionData
impl UnsafeUnpin for SessionData
impl UnwindSafe for SessionData
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.