pub struct CredentialStuffingDetector { /* private fields */ }Expand description
Credential stuffing detector with concurrent access.
SECURITY: Implements multi-dimensional detection to catch distributed attacks:
- Per-entity (IP) failure tracking
- Fingerprint-based distributed attack correlation
- Username-targeted attack detection (multiple IPs targeting same username)
- Global velocity monitoring for coordinated attacks
Implementations§
Source§impl CredentialStuffingDetector
impl CredentialStuffingDetector
Sourcepub fn new(config: StuffingConfig) -> Self
pub fn new(config: StuffingConfig) -> Self
Create a new detector with the given configuration.
Configuration is validated and sanitized before use.
Sourcepub fn with_defaults() -> Self
pub fn with_defaults() -> Self
Create with default configuration.
Sourcepub fn is_auth_endpoint(&self, path: &str) -> bool
pub fn is_auth_endpoint(&self, path: &str) -> bool
Check if an endpoint is an auth endpoint.
Sourcepub fn record_attempt(&self, attempt: &AuthAttempt) -> StuffingVerdict
pub fn record_attempt(&self, attempt: &AuthAttempt) -> StuffingVerdict
Record an auth attempt (request phase).
Call this when a request hits an auth endpoint. Returns a verdict that may adjust risk or block.
Sourcepub fn record_result(&self, result: &AuthResult) -> Option<TakeoverAlert>
pub fn record_result(&self, result: &AuthResult) -> Option<TakeoverAlert>
Record an auth result (response phase).
Call this when auth response is known (success/failure). Checks for account takeover pattern.
Sourcepub fn record_distributed_failure(
&self,
fingerprint: &str,
endpoint: &str,
now: u64,
)
pub fn record_distributed_failure( &self, fingerprint: &str, endpoint: &str, now: u64, )
Record a failure in distributed attack tracking.
Sourcepub fn get_entity_metrics(
&self,
entity_id: &str,
endpoint: &str,
) -> Option<AuthMetrics>
pub fn get_entity_metrics( &self, entity_id: &str, endpoint: &str, ) -> Option<AuthMetrics>
Get entity’s auth metrics.
Sourcepub fn get_all_entity_metrics(&self) -> Vec<AuthMetrics>
pub fn get_all_entity_metrics(&self) -> Vec<AuthMetrics>
Get all entity metrics.
Sourcepub fn get_distributed_attacks(&self) -> Vec<DistributedAttack>
pub fn get_distributed_attacks(&self) -> Vec<DistributedAttack>
Get active distributed attacks.
Sourcepub fn get_takeover_alerts(&self, since: u64) -> Vec<TakeoverAlert>
pub fn get_takeover_alerts(&self, since: u64) -> Vec<TakeoverAlert>
Get recent takeover alerts.
Sourcepub fn get_all_takeover_alerts(&self) -> Vec<TakeoverAlert>
pub fn get_all_takeover_alerts(&self) -> Vec<TakeoverAlert>
Get all takeover alerts.
Sourcepub fn get_events(&self, since: u64) -> Vec<StuffingEvent>
pub fn get_events(&self, since: u64) -> Vec<StuffingEvent>
Get recent events since timestamp.
Sourcepub fn drain_events(&self) -> Vec<StuffingEvent>
pub fn drain_events(&self) -> Vec<StuffingEvent>
Get all events.
Sourcepub fn get_stats(&self) -> StuffingStats
pub fn get_stats(&self) -> StuffingStats
Get statistics.
Sourcepub fn export(&self) -> StuffingState
pub fn export(&self) -> StuffingState
Export state for persistence.
Sourcepub fn import(&self, state: StuffingState)
pub fn import(&self, state: StuffingState)
Import state from persistence.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for CredentialStuffingDetector
impl !RefUnwindSafe for CredentialStuffingDetector
impl Send for CredentialStuffingDetector
impl Sync for CredentialStuffingDetector
impl Unpin for CredentialStuffingDetector
impl UnsafeUnpin for CredentialStuffingDetector
impl !UnwindSafe for CredentialStuffingDetector
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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