pub struct SessionConfig {
pub idle_lifetime: Duration,
pub absolute_lifetime: Duration,
pub cookie_name: String,
pub cookie_path: String,
pub cookie_secure: bool,
pub cookie_http_only: bool,
pub cookie_same_site: String,
pub table_name: String,
}Expand description
Session configuration with dual timeout support (idle + absolute).
Idle timeout expires sessions after inactivity. Absolute timeout expires sessions after a fixed period since creation, regardless of activity. Both are enforced server-side per OWASP session management guidelines.
Fields§
§idle_lifetime: DurationIdle timeout: session expires after this duration of inactivity
absolute_lifetime: DurationAbsolute timeout: session expires this duration after creation, regardless of activity
Cookie name for the session ID
Cookie path
Whether to set Secure flag on cookie (HTTPS only)
Whether to set HttpOnly flag on cookie
SameSite attribute for the cookie
table_name: StringDatabase table name for sessions
Implementations§
Source§impl SessionConfig
impl SessionConfig
Sourcepub fn from_env() -> Self
pub fn from_env() -> Self
Load session configuration from environment variables
Environment variables:
SESSION_LIFETIME: Idle timeout in minutes (default: 120)SESSION_ABSOLUTE_LIFETIME: Absolute timeout in minutes (default: 43200 / 30 days)SESSION_COOKIE: Cookie name (default: ferro_session)SESSION_SECURE: Set Secure flag (default: true)SESSION_PATH: Cookie path (default: /)SESSION_SAME_SITE: SameSite attribute (default: Lax)
Sourcepub fn idle_lifetime(self, duration: Duration) -> Self
pub fn idle_lifetime(self, duration: Duration) -> Self
Set the idle timeout duration
Sourcepub fn absolute_lifetime(self, duration: Duration) -> Self
pub fn absolute_lifetime(self, duration: Duration) -> Self
Set the absolute timeout duration
Set the cookie name
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 moreSource§impl Debug for SessionConfig
impl Debug for SessionConfig
Auto Trait Implementations§
impl Freeze for SessionConfig
impl RefUnwindSafe for SessionConfig
impl Send for SessionConfig
impl Sync for SessionConfig
impl Unpin for SessionConfig
impl UnsafeUnpin 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