Skip to main content

px_auth/domain/
audit_event.rs

1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
4#[non_exhaustive]
5pub enum AuditOutcome {
6    Solved,
7    CacheHit,
8    AuthDenied,
9    AllowlistDenied,
10    HandlerFailed,
11}
12
13#[derive(Debug, Clone, Serialize, Deserialize)]
14pub struct AuditEvent {
15    pub timestamp_unix: u64,
16    pub key_id: String,
17    pub target_domain: String,
18    pub outcome: AuditOutcome,
19    pub latency_ms: u64,
20    pub handler: Option<String>,
21}
22
23impl AuditEvent {
24    pub fn redacted_json(&self) -> Result<String, serde_json::Error> {
25        serde_json::to_string(self)
26    }
27}