pub struct SessionConfig {
pub session_ttl_secs: u64,
pub cookie_name: String,
pub validate_fingerprint: bool,
pub touch_interval_secs: u64,
pub max_sessions_per_user: usize,
pub trusted_proxies: Vec<String>,
}Expand description
Configuration for the session subsystem.
All fields have sane defaults (see Default). Deserialises from YAML/TOML
with #[serde(default)], so you only need to specify the fields you want to
override.
§Example (YAML)
session_ttl_secs: 86400
cookie_name: "_sess"
validate_fingerprint: true
touch_interval_secs: 600
max_sessions_per_user: 5
trusted_proxies:
- "10.0.0.0/8"Fields§
§session_ttl_secs: u64Session lifetime in seconds (default: 2 592 000 = 30 days).
Name of the HTTP cookie that carries the session token (default: "_session").
validate_fingerprint: boolWhether to reject sessions whose request fingerprint changed since creation
(default: true). Disabling this reduces hijack protection but allows users
behind rotating IPs or proxies to keep their session.
touch_interval_secs: u64Minimum number of seconds between consecutive touch (expiry renewal) DB
writes (default: 300 = 5 minutes).
max_sessions_per_user: usizeMaximum number of concurrent active sessions per user before the least-recently-used session is evicted (default: 10).
trusted_proxies: Vec<String>CIDR ranges of trusted reverse-proxy addresses. When non-empty, the
X-Forwarded-For / X-Real-IP headers are only trusted when the TCP
connection originates from one of these ranges (default: empty = trust
proxy headers unconditionally).
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
Source§impl Default for SessionConfig
impl Default for SessionConfig
Source§impl<'de> Deserialize<'de> for SessionConfigwhere
SessionConfig: Default,
impl<'de> Deserialize<'de> for SessionConfigwhere
SessionConfig: Default,
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>,
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