pub struct SessionManager<S: SessionStorage, A: AuditStorage> { /* private fields */ }
Expand description
Main session manager
Implementations§
Source§impl<S: SessionStorage, A: AuditStorage> SessionManager<S, A>
impl<S: SessionStorage, A: AuditStorage> SessionManager<S, A>
Sourcepub fn new(
storage: S,
config: SessionConfig,
audit_logger: AuditLogger<A>,
) -> Self
pub fn new( storage: S, config: SessionConfig, audit_logger: AuditLogger<A>, ) -> Self
Create a new session manager
Sourcepub async fn create_session(
&self,
user_id: &str,
device_info: DeviceInfo,
metadata: RequestMetadata,
) -> Result<Session>
pub async fn create_session( &self, user_id: &str, device_info: DeviceInfo, metadata: RequestMetadata, ) -> Result<Session>
Create a new session
Sourcepub async fn validate_session(
&self,
session_id: &str,
metadata: RequestMetadata,
) -> Result<Option<Session>>
pub async fn validate_session( &self, session_id: &str, metadata: RequestMetadata, ) -> Result<Option<Session>>
Validate and refresh a session
Sourcepub async fn revoke_session(&self, session_id: &str) -> Result<()>
pub async fn revoke_session(&self, session_id: &str) -> Result<()>
Revoke a session
Sourcepub async fn revoke_all_user_sessions(&self, user_id: &str) -> Result<u32>
pub async fn revoke_all_user_sessions(&self, user_id: &str) -> Result<u32>
Revoke all sessions for a user
Sourcepub async fn get_user_sessions(
&self,
user_id: &str,
include_inactive: bool,
) -> Result<Vec<Session>>
pub async fn get_user_sessions( &self, user_id: &str, include_inactive: bool, ) -> Result<Vec<Session>>
Get user sessions with filtering
Sourcepub async fn cleanup_expired_sessions(&self) -> Result<u32>
pub async fn cleanup_expired_sessions(&self) -> Result<u32>
Clean up expired sessions
Sourcepub fn generate_device_fingerprint(&self, metadata: &RequestMetadata) -> String
pub fn generate_device_fingerprint(&self, metadata: &RequestMetadata) -> String
Generate device fingerprint for given request metadata
Sourcepub fn validate_device_fingerprint(
&self,
session: &Session,
metadata: &RequestMetadata,
) -> bool
pub fn validate_device_fingerprint( &self, session: &Session, metadata: &RequestMetadata, ) -> bool
Validate device fingerprint against session
Auto Trait Implementations§
impl<S, A> !Freeze for SessionManager<S, A>
impl<S, A> !RefUnwindSafe for SessionManager<S, A>
impl<S, A> Send for SessionManager<S, A>
impl<S, A> Sync for SessionManager<S, A>
impl<S, A> Unpin for SessionManager<S, A>
impl<S, A> !UnwindSafe for SessionManager<S, A>
Blanket Implementations§
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<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
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>
Converts
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>
Converts
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 more