pub struct SessionConfig {
pub auth_token_ttl: Duration,
pub refresh_token_ttl: Duration,
pub proactive_renewal_window: Duration,
pub renewal_lease_ttl: LeaseTtl,
pub clock_skew_tolerance: Duration,
}Expand description
Configuration for session issuance and renewal behavior.
This type intentionally stays free of HTTP-specific concerns such as cookie names, headers, or response mutation. Adapter crates should translate these values into transport-specific behavior at the system edge.
§Examples
use std::time::Duration;
use webgates_sessions::config::SessionConfig;
use webgates_sessions::lease::LeaseTtl;
// Use defaults for a typical production setup.
let config = SessionConfig::default();
assert!(config.is_valid());
// Or supply explicit values.
let config = SessionConfig::new(
Duration::from_secs(15 * 60), // auth token TTL: 15 min
Duration::from_secs(30 * 24 * 3600), // refresh token TTL: 30 days
Duration::from_secs(2 * 60), // proactive renewal window: 2 min
LeaseTtl::new(Duration::from_secs(30)),
Duration::from_secs(5), // clock-skew tolerance: 5 s
)
.validate()
.unwrap();
assert!(config.is_valid());Fields§
§auth_token_ttl: DurationLifetime of the short-lived authentication token.
refresh_token_ttl: DurationLifetime of the long-lived refresh token.
proactive_renewal_window: DurationWindow before auth-token expiry during which proactive renewal is allowed.
renewal_lease_ttl: LeaseTtlTyped duration for which a renewal lease remains valid once acquired.
clock_skew_tolerance: DurationMaximum amount of clock skew tolerated by renewal decision logic.
Implementations§
Source§impl SessionConfig
impl SessionConfig
Sourcepub const fn new(
auth_token_ttl: Duration,
refresh_token_ttl: Duration,
proactive_renewal_window: Duration,
renewal_lease_ttl: LeaseTtl,
clock_skew_tolerance: Duration,
) -> Self
pub const fn new( auth_token_ttl: Duration, refresh_token_ttl: Duration, proactive_renewal_window: Duration, renewal_lease_ttl: LeaseTtl, clock_skew_tolerance: Duration, ) -> Self
Creates a configuration with explicit values.
Sourcepub fn renewal_lease_duration(&self) -> Duration
pub fn renewal_lease_duration(&self) -> Duration
Returns the configured lease TTL as a raw duration.
Sourcepub fn validate(self) -> ConfigResult<Self>
pub fn validate(self) -> ConfigResult<Self>
Validates the configuration and returns the typed value when it is internally consistent.
§Errors
Returns a configuration error when one of the required durations is zero or when the proactive renewal window exceeds the auth-token lifetime.
Trait Implementations§
Source§impl Clone for SessionConfig
impl Clone for SessionConfig
Source§fn clone(&self) -> SessionConfig
fn clone(&self) -> SessionConfig
1.0.0 (const: unstable) · 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 PartialEq for SessionConfig
impl PartialEq for SessionConfig
Source§fn eq(&self, other: &SessionConfig) -> bool
fn eq(&self, other: &SessionConfig) -> bool
self and other values to be equal, and is used by ==.