pub struct SessionManager { /* private fields */ }
Expand description
Session manager for handling user sessions
Implementations§
Source§impl SessionManager
impl SessionManager
Sourcepub fn new(storage: Arc<dyn AuthStorage>) -> Self
pub fn new(storage: Arc<dyn AuthStorage>) -> Self
Create a new session manager
Sourcepub async fn create_session(
&self,
user_id: &str,
expires_in: Duration,
ip_address: Option<String>,
user_agent: Option<String>,
) -> Result<String>
pub async fn create_session( &self, user_id: &str, expires_in: Duration, ip_address: Option<String>, user_agent: Option<String>, ) -> Result<String>
Create a new session
Sourcepub async fn get_session(&self, session_id: &str) -> Result<Option<SessionData>>
pub async fn get_session(&self, session_id: &str) -> Result<Option<SessionData>>
Get session information
Sourcepub async fn delete_session(&self, session_id: &str) -> Result<()>
pub async fn delete_session(&self, session_id: &str) -> Result<()>
Delete a session
Sourcepub async fn update_session_activity(&self, session_id: &str) -> Result<()>
pub async fn update_session_activity(&self, session_id: &str) -> Result<()>
Update session last activity
Sourcepub async fn get_user_sessions(
&self,
user_id: &str,
) -> Result<Vec<(String, SessionData)>>
pub async fn get_user_sessions( &self, user_id: &str, ) -> Result<Vec<(String, SessionData)>>
Get all sessions for a user
Sourcepub async fn delete_user_sessions(&self, user_id: &str) -> Result<()>
pub async fn delete_user_sessions(&self, user_id: &str) -> Result<()>
Delete all sessions for a user
Sourcepub async fn cleanup_expired_sessions(&self) -> Result<()>
pub async fn cleanup_expired_sessions(&self) -> Result<()>
Clean up expired sessions
Sourcepub async fn validate_session(&self, session_id: &str) -> Result<Option<String>>
pub async fn validate_session(&self, session_id: &str) -> Result<Option<String>>
Validate session and return user info
Sourcepub async fn extend_session(
&self,
session_id: &str,
additional_time: Duration,
) -> Result<()>
pub async fn extend_session( &self, session_id: &str, additional_time: Duration, ) -> Result<()>
Extend session expiration
Sourcepub async fn count_active_sessions(&self) -> Result<u64>
pub async fn count_active_sessions(&self) -> Result<u64>
Count the number of currently active sessions Used for security audit statistics
Auto Trait Implementations§
impl Freeze for SessionManager
impl !RefUnwindSafe for SessionManager
impl Send for SessionManager
impl Sync for SessionManager
impl Unpin for SessionManager
impl !UnwindSafe for SessionManager
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