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]
47pub trait AuthzAuditSink: Send + Sync + std::fmt::Debug {
48 async fn record(&self, req: &AuthzRequest, decision: &AuthzDecision, source: AuthzSource);
49}
50
51#[derive(Debug, Default, Clone, Copy)]
52pub struct NullAuditSink;
53
54#[async_trait]
55impl AuthzAuditSink for NullAuditSink {
56 async fn record(&self, _req: &AuthzRequest, _decision: &AuthzDecision, _source: AuthzSource) {}
57}