pub struct SessionConfig { /* private fields */ }Expand description
Session authentication configuration.
§Spring Security Equivalent
Combines SessionManagementConfigurer and SessionFixationConfigurer.
§Example
let config = SessionConfig::new()
.user_key("user")
.fixation_strategy(SessionFixationStrategy::MigrateSession)
.maximum_sessions(1); // Only one session per userImplementations§
Source§impl SessionConfig
impl SessionConfig
Sourcepub fn authenticated_key(self, key: &str) -> Self
pub fn authenticated_key(self, key: &str) -> Self
Set the session key for authentication flag.
Sourcepub fn saved_request_key(self, key: &str) -> Self
pub fn saved_request_key(self, key: &str) -> Self
Set the session key for saved request URL.
Sourcepub fn fixation_strategy(self, strategy: SessionFixationStrategy) -> Self
pub fn fixation_strategy(self, strategy: SessionFixationStrategy) -> Self
Set the session fixation protection strategy.
§Spring Equivalent
sessionManagement().sessionFixation().migrateSession()
Sourcepub fn maximum_sessions(self, max: usize) -> Self
pub fn maximum_sessions(self, max: usize) -> Self
Set the maximum number of concurrent sessions per user.
§Spring Equivalent
sessionManagement().maximumSessions(1)
Sourcepub fn timeout(self, duration: Duration) -> Self
pub fn timeout(self, duration: Duration) -> Self
Set the session timeout duration. Note: This is informational; actual timeout is configured in SessionMiddleware.
Sourcepub fn expire_oldest_session(self, expire: bool) -> Self
pub fn expire_oldest_session(self, expire: bool) -> Self
Whether to expire the oldest session when maximum sessions exceeded.
§Spring Equivalent
sessionManagement().maximumSessions(1).expiredSessionStrategy(...)
Sourcepub fn get_user_key(&self) -> &str
pub fn get_user_key(&self) -> &str
Get the user key.
Sourcepub fn get_authenticated_key(&self) -> &str
pub fn get_authenticated_key(&self) -> &str
Get the authenticated key.
Sourcepub fn get_saved_request_key(&self) -> &str
pub fn get_saved_request_key(&self) -> &str
Get the saved request key.
Sourcepub fn get_fixation_strategy(&self) -> SessionFixationStrategy
pub fn get_fixation_strategy(&self) -> SessionFixationStrategy
Get the fixation strategy.
Sourcepub fn get_maximum_sessions(&self) -> Option<usize>
pub fn get_maximum_sessions(&self) -> Option<usize>
Get maximum sessions.
Sourcepub fn get_timeout(&self) -> Option<Duration>
pub fn get_timeout(&self) -> Option<Duration>
Get timeout.
Sourcepub fn should_expire_oldest(&self) -> bool
pub fn should_expire_oldest(&self) -> bool
Check if oldest session should be expired.
Trait Implementations§
Source§impl Clone for SessionConfig
impl Clone for SessionConfig
Source§fn clone(&self) -> SessionConfig
fn clone(&self) -> SessionConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for SessionConfig
impl RefUnwindSafe for SessionConfig
impl Send for SessionConfig
impl Sync for SessionConfig
impl Unpin for SessionConfig
impl UnwindSafe for SessionConfig
Blanket Implementations§
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 more