#[non_exhaustive]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 cookie: CookieConfig,
}Expand description
Configuration for the cookie-backed session middleware.
Deserialised from the session key in the application YAML config.
All fields have defaults, so an empty session: block is valid.
§YAML example
session:
session_ttl_secs: 2592000 # 30 days
cookie_name: "_session"
validate_fingerprint: true
touch_interval_secs: 300 # 5 minutes
max_sessions_per_user: 10
cookie:
secret: "your-secret-here"
secure: true
http_only: true
same_site: "lax"Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.session_ttl_secs: u64Session lifetime in seconds. Defaults to 2_592_000 (30 days).
Name of the session cookie. Defaults to "_session".
validate_fingerprint: boolWhen true, the middleware rejects requests whose browser fingerprint
does not match the one recorded at login. Defaults to true.
touch_interval_secs: u64Minimum interval between last_active_at updates, in seconds.
A session is only touched when at least this many seconds have elapsed
since the last touch. Defaults to 300 (5 minutes).
max_sessions_per_user: usizeMaximum number of concurrent active sessions per user. When exceeded,
the least-recently-used session is evicted. Must be greater than zero.
Defaults to 10.
Cookie security attributes (secret, secure flag, HttpOnly, SameSite).
Trait Implementations§
Source§impl Clone for CookieSessionsConfig
impl Clone for CookieSessionsConfig
Source§fn clone(&self) -> CookieSessionsConfig
fn clone(&self) -> CookieSessionsConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more