systemprompt_security/authz/audit/
mod.rs1mod db_sink;
15mod repository;
16
17use async_trait::async_trait;
18
19use super::types::{AuthzDecision, AuthzRequest};
20
21pub use db_sink::DbAuditSink;
22pub use repository::{
23 GovernanceDecisionRecord, GovernanceDecisionRepository, insert_governance_decision,
24};
25
26#[derive(Debug, Clone, Copy, PartialEq, Eq)]
27pub enum AuthzSource {
28 WebhookFault,
29 DenyAllDefault,
30 AllowAllUnrestricted,
31}
32
33impl AuthzSource {
34 pub const fn policy(self) -> &'static str {
35 match self {
36 Self::WebhookFault => "authz_hook_fault",
37 Self::DenyAllDefault => "authz_default_deny",
38 Self::AllowAllUnrestricted => "authz_unrestricted",
39 }
40 }
41}
42
43#[async_trait]
44pub trait AuthzAuditSink: Send + Sync + std::fmt::Debug {
45 async fn record(&self, req: &AuthzRequest, decision: &AuthzDecision, source: AuthzSource);
46}
47
48#[derive(Debug, Default, Clone, Copy)]
49pub struct NullAuditSink;
50
51#[async_trait]
52impl AuthzAuditSink for NullAuditSink {
53 async fn record(&self, _req: &AuthzRequest, _decision: &AuthzDecision, _source: AuthzSource) {}
54}