pub struct ReplayDefensePolicy {
pub rotation_interval: Duration,
pub nonce_validity_window: Duration,
pub force_reset_on_drift: bool,
}Expand description
Adaptive session-replay defense policy.
The three levers are independent and the runner combines them to decide when a session must be rotated or reset:
rotation_interval— max age of a session before it is forcibly rotated.nonce_validity_window— max age of the session nonce the challenge / challenge-response endpoint issued.force_reset_on_drift— whether signature drift triggers an immediate session reset.
§Example
use stygian_browser::replay_defense::ReplayDefensePolicy;
use std::time::Duration;
let policy = ReplayDefensePolicy {
rotation_interval: Duration::from_mins(15),
..ReplayDefensePolicy::default()
};
assert_eq!(policy.rotation_interval, Duration::from_mins(15));
assert!(policy.force_reset_on_drift);Fields§
§rotation_interval: DurationMaximum age of a session before a forced rotation. The
check function emits ReplayDefenseDecision::RotationDue
once elapsed >= rotation_interval.
nonce_validity_window: DurationMaximum age of a session nonce. After this window the
nonce is no longer trustworthy and the session must be
re-bound to a fresh nonce. The check function emits
ReplayDefenseDecision::NonceExpired once
nonce_age >= nonce_validity_window.
force_reset_on_drift: boolWhen true, signature drift (observed_signature != captured_signature) triggers a forced refresh of the sticky
browser context. When false, drift is reported but the
runner continues.
Implementations§
Source§impl ReplayDefensePolicy
impl ReplayDefensePolicy
Sourcepub const fn with_rotation_interval(rotation_interval: Duration) -> Self
pub const fn with_rotation_interval(rotation_interval: Duration) -> Self
Build a policy with explicit rotation interval and defaults for the other fields.
Sourcepub const fn with_nonce_validity_window(nonce_validity_window: Duration) -> Self
pub const fn with_nonce_validity_window(nonce_validity_window: Duration) -> Self
Build a policy with an explicit nonce validity window and defaults for the other fields.
Sourcepub const fn with_rotation(self, rotation_interval: Duration) -> Self
pub const fn with_rotation(self, rotation_interval: Duration) -> Self
Replace the rotation interval.
Sourcepub const fn with_nonce_window(self, nonce_validity_window: Duration) -> Self
pub const fn with_nonce_window(self, nonce_validity_window: Duration) -> Self
Replace the nonce validity window.
Sourcepub const fn with_force_reset_on_drift(self, force: bool) -> Self
pub const fn with_force_reset_on_drift(self, force: bool) -> Self
Replace the force_reset_on_drift flag.
Sourcepub fn validate(&self) -> Result<(), ReplayDefenseError>
pub fn validate(&self) -> Result<(), ReplayDefenseError>
Validate the policy. rotation_interval and
nonce_validity_window must be strictly positive.
§Errors
Returns ReplayDefenseError::InvalidField when either
interval is zero.
Trait Implementations§
Source§impl Clone for ReplayDefensePolicy
impl Clone for ReplayDefensePolicy
Source§fn clone(&self) -> ReplayDefensePolicy
fn clone(&self) -> ReplayDefensePolicy
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more