pub struct GuardConfigBuilder { /* private fields */ }Expand description
Builder for GuardConfig.
Implementations§
Source§impl GuardConfigBuilder
impl GuardConfigBuilder
Cookie attributes. See CookieConfig.
Shorthand for changing only the cookie name.
Sourcepub fn session_lifetime(self, lifetime: Duration) -> Self
pub fn session_lifetime(self, lifetime: Duration) -> Self
Absolute session lifetime, counted from login. Activity, rotation and step-up never extend it; the subject must log in again. Default 30 days.
Sourcepub fn idle_timeout(self, timeout: Duration) -> Self
pub fn idle_timeout(self, timeout: Duration) -> Self
Inactivity timeout. Default 7 days.
Sourcepub fn trusted_proxies<I, T>(self, proxies: I) -> Result<Self, ConfigError>
pub fn trusted_proxies<I, T>(self, proxies: I) -> Result<Self, ConfigError>
Reverse proxies (IP addresses or CIDR ranges) whose X-Forwarded-For is honoured.
Without any, the TCP peer address is the client address.
§Errors
ConfigError::InvalidProxy for an entry that is not an IP or CIDR range.
Sourcepub fn tls_fingerprint_header(self, header: impl Into<String>) -> Self
pub fn tls_fingerprint_header(self, header: impl Into<String>) -> Self
Header with a TLS fingerprint (e.g. JA4) set by your proxy. Enables
Check::TlsChanged. Only use a header your proxy
overwrites on every request.
Sourcepub fn rotation(self, rotation: RotationConfig) -> Self
pub fn rotation(self, rotation: RotationConfig) -> Self
Token rotation settings.
Sourcepub fn checks(self, checks: Checks) -> Self
pub fn checks(self, checks: Checks) -> Self
Checks and weights. Default: all checks at default weights.
Sourcepub fn thresholds(self, thresholds: Thresholds) -> Self
pub fn thresholds(self, thresholds: Thresholds) -> Self
Score thresholds. Default: step-up at 40, revoke at 80.
Sourcepub fn step_up_policy(self, policy: StepUpPolicy) -> Self
pub fn step_up_policy(self, policy: StepUpPolicy) -> Self
What a step-up decision does. Default StepUpPolicy::Require.
Sourcepub fn orphan_reissue_window(self, window: Duration) -> Self
pub fn orphan_reissue_window(self, window: Duration) -> Self
How long after being superseded an orphaned token (its successor never presented) is
still reissued. Past it the token is rejected as unknown and the session is left to
whoever holds the successor. Default off: orphans are reissued until
rotation.reuse_detection prunes them.
Zero never reissues: a client that loses a single rotation response is signed out.
Sourcepub fn ping_pong_window(self, window: Duration) -> Self
pub fn ping_pong_window(self, window: Duration) -> Self
Ping-pong window. Default 5 minutes. Zero disables ping-pong detection.
Sourcepub fn last_seen_write_interval(self, interval: Duration) -> Self
pub fn last_seen_write_interval(self, interval: Duration) -> Self
How stale last_seen may get before an unchanged request writes it. Default 60 seconds.
Zero writes on every request.
Sourcepub fn event_retention(self, retention: Duration) -> Self
pub fn event_retention(self, retention: Duration) -> Self
Event retention. Default 90 days.
Sourcepub fn minimize_stored_events(self, minimize: bool) -> Self
pub fn minimize_stored_events(self, minimize: bool) -> Self
Write a reduced copy of each event to the store: the IP’s /24 (IPv4) or /48 (IPv6)
network instead of the address, no raw User-Agent (the browser and OS families stay in
ClientSummary) and no city. Default on. The
on_event hook always gets the full event.
Sourcepub fn keep_origin_client(self, keep: bool) -> Self
pub fn keep_origin_client(self, keep: bool) -> Self
Keep the full IP, raw User-Agent and city in each session’s
SessionOrigin. Default off: the origin holds only the IP’s
/24 (IPv4) or /48 (IPv6) network and the ClientSummary
without city, which is enough for a “your devices” page.
Sourcepub fn shadow_dedup_window(self, window: Duration) -> Self
pub fn shadow_dedup_window(self, window: Duration) -> Self
Shadow event dedup window. Default 10 minutes. Zero records every shadow event.
Sourcepub fn alert_dedup_window(self, window: Duration) -> Self
pub fn alert_dedup_window(self, window: Duration) -> Self
Per-subject alert dedup window. Default zero (off).
When set, the hook sees at most one enforced security-relevant event per subject and
kind per window, across processes through SessionStore::claim_event with
ClaimScope::Subject. Use it so an attacker hammering many sessions of one subject
pages its owner once instead of once per session. Every event is still logged and
stored; login, logout and step-up completion always reach the hook.
Sourcepub fn max_header_len(self, len: usize) -> Self
pub fn max_header_len(self, len: usize) -> Self
Maximum header value length considered. Longer values are truncated. Default 512.
Sourcepub fn token_prefix(self, prefix: impl Into<String>) -> Self
pub fn token_prefix(self, prefix: impl Into<String>) -> Self
Prefix for issued tokens, such as "sess_". Default none.
The cookie value becomes the prefix followed by the usual 43 characters, and any presented
token without the prefix is rejected before the store is consulted. Use it to tell browser
sessions apart from other credentials at a glance (for example pat_ and svc_ API keys
handled elsewhere), and to let secret scanners recognise leaked tokens. The prefix is not
secret and is not part of the stored hash.
Sourcepub fn build(self) -> Result<GuardConfig, ConfigError>
pub fn build(self) -> Result<GuardConfig, ConfigError>
Validates and builds.
§Errors
ConfigError for invalid cookie attributes, zero or oversized durations, a grace not
shorter than the rotation interval, invalid thresholds, header names or token prefix.
Trait Implementations§
Source§impl Clone for GuardConfigBuilder
impl Clone for GuardConfigBuilder
Source§impl Debug for GuardConfigBuilder
impl Debug for GuardConfigBuilder
Auto Trait Implementations§
impl Freeze for GuardConfigBuilder
impl RefUnwindSafe for GuardConfigBuilder
impl Send for GuardConfigBuilder
impl Sync for GuardConfigBuilder
impl Unpin for GuardConfigBuilder
impl UnsafeUnpin for GuardConfigBuilder
impl UnwindSafe for GuardConfigBuilder
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