pub struct SecurityEvent {
pub id: String,
pub timestamp: u64,
pub event_type: SecurityEventType,
pub severity: SecurityEventSeverity,
pub username: Option<String>,
pub ip_address: Option<String>,
pub user_agent: Option<String>,
pub path: Option<String>,
pub method: Option<String>,
pub session_id: Option<String>,
pub details: HashMap<String, String>,
pub error: Option<String>,
}Expand description
A security audit event.
Fields§
§id: StringUnique event ID
timestamp: u64Event timestamp (Unix epoch milliseconds)
event_type: SecurityEventTypeEvent type
severity: SecurityEventSeverityEvent severity
username: Option<String>Username (if applicable)
ip_address: Option<String>Source IP address
user_agent: Option<String>User agent
path: Option<String>Request path
method: Option<String>HTTP method
session_id: Option<String>Session ID (if applicable)
details: HashMap<String, String>Additional details
error: Option<String>Error message (for failure events)
Implementations§
Source§impl SecurityEvent
impl SecurityEvent
Sourcepub fn new(event_type: SecurityEventType) -> Self
pub fn new(event_type: SecurityEventType) -> Self
Create a new security event.
Sourcepub fn ip_address(self, ip: impl Into<String>) -> Self
pub fn ip_address(self, ip: impl Into<String>) -> Self
Set the IP address.
Sourcepub fn user_agent(self, ua: impl Into<String>) -> Self
pub fn user_agent(self, ua: impl Into<String>) -> Self
Set the user agent.
Sourcepub fn session_id(self, id: impl Into<String>) -> Self
pub fn session_id(self, id: impl Into<String>) -> Self
Set the session ID.
Sourcepub fn severity(self, severity: SecurityEventSeverity) -> Self
pub fn severity(self, severity: SecurityEventSeverity) -> Self
Set the severity (overrides default).
Sourcepub fn login_success(username: &str, ip: &str) -> Self
pub fn login_success(username: &str, ip: &str) -> Self
Create a login success event.
Sourcepub fn login_failure(username: &str, ip: &str, reason: &str) -> Self
pub fn login_failure(username: &str, ip: &str, reason: &str) -> Self
Create a login failure event.
Sourcepub fn access_denied(username: &str, path: &str, ip: &str) -> Self
pub fn access_denied(username: &str, path: &str, ip: &str) -> Self
Create an access denied event.
Sourcepub fn rate_limit_exceeded(ip: &str, path: &str) -> Self
pub fn rate_limit_exceeded(ip: &str, path: &str) -> Self
Create a rate limit exceeded event.
Sourcepub fn account_locked(username: &str, ip: &str, reason: &str) -> Self
pub fn account_locked(username: &str, ip: &str, reason: &str) -> Self
Create an account locked event.
Sourcepub fn brute_force_detected(ip: &str, attempts: u32) -> Self
pub fn brute_force_detected(ip: &str, attempts: u32) -> Self
Create a brute force detected event.
Sourcepub fn to_log_line(&self) -> String
pub fn to_log_line(&self) -> String
Format the event as a log line.
Trait Implementations§
Source§impl Clone for SecurityEvent
impl Clone for SecurityEvent
Source§fn clone(&self) -> SecurityEvent
fn clone(&self) -> SecurityEvent
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SecurityEvent
impl Debug for SecurityEvent
Auto Trait Implementations§
impl Freeze for SecurityEvent
impl RefUnwindSafe for SecurityEvent
impl Send for SecurityEvent
impl Sync for SecurityEvent
impl Unpin for SecurityEvent
impl UnwindSafe for SecurityEvent
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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