pub struct AuditEvent {
pub kind: VerifyErrorKind,
pub occurred_at: OffsetDateTime,
pub source_id: String,
pub client_id_hint: Option<String>,
pub kid_hint: Option<String>,
pub metadata: BTreeMap<String, Value>,
}Expand description
Single typed event emitted on every BearerVerifier::verify rejection.
kind drives audit-pivot grouping; source_id drives rate-limiting
and per-source dashboards; metadata carries free-form context
(engine M-row identifier for Other, claim names, etc.).
Best-effort hint decoding: client_id_hint and kid_hint come
from the rejected token’s payload/header via defensive base64+JSON
parse. Either may be None if the token was malformed; callers MUST
NOT treat absence as a security signal — by definition the token
was rejected, so its claims are untrusted. The hints exist for
grouping, not authentication.
source_id derivation: per Phase 9 design call (e), source_id
is the compound client_id_hint ‖ kid_hint key. Anonymous /
kid-less rejections collapse into a canonical "anon::nokid"
bucket so attacker-controlled token mangling can’t explode the
bucket count. See compose_source_id and AuditEvent::from_hints.
All fields are pub so adapters can serialize them or pivot on
arbitrary subsets. The canonical construction path is
AuditEvent::from_hints, which guarantees source_id matches
the hints. Hand-constructing with mismatched values is technically
possible (and useful for fault-injection in tests) but a code
review concern in production.
Fields§
§kind: VerifyErrorKindFailure classification — drives audit-pivot grouping.
occurred_at: OffsetDateTimeWall-clock at engine reject (UTC, RFC 3339 wire format).
source_id: StringCompound client_id_hint ‖ kid_hint key for rate-limiting +
per-source pivot.
client_id_hint: Option<String>Best-effort client_id claim from the rejected token’s payload.
kid_hint: Option<String>Best-effort kid from the rejected token’s header.
metadata: BTreeMap<String, Value>Free-form structured context — engine M-row identifier for
Other, claim names for telemetry, etc. BTreeMap (not
HashMap) for deterministic ordering in snapshot tests.
Implementations§
Source§impl AuditEvent
impl AuditEvent
Sourcepub fn from_hints(
kind: VerifyErrorKind,
occurred_at: OffsetDateTime,
client_id_hint: Option<String>,
kid_hint: Option<String>,
metadata: BTreeMap<String, Value>,
) -> AuditEvent
pub fn from_hints( kind: VerifyErrorKind, occurred_at: OffsetDateTime, client_id_hint: Option<String>, kid_hint: Option<String>, metadata: BTreeMap<String, Value>, ) -> AuditEvent
Canonical constructor — composes source_id from the hints so
the two never disagree. Production callers (Phase 9.D
PasJwtVerifier::verify) use this.
Sourcepub fn from_id_token_hints(
kind: VerifyErrorKind,
occurred_at: OffsetDateTime,
azp_hint: Option<String>,
aud_hint: Option<String>,
kid_hint: Option<String>,
metadata: BTreeMap<String, Value>,
) -> AuditEvent
pub fn from_id_token_hints( kind: VerifyErrorKind, occurred_at: OffsetDateTime, azp_hint: Option<String>, aud_hint: Option<String>, kid_hint: Option<String>, metadata: BTreeMap<String, Value>, ) -> AuditEvent
id_token-specific canonical constructor (Phase 10.11.D, δ2).
Composes the 3-tuple azp ‖ aud ‖ kid source key — strongest
per-source discrimination for log-flood DoS prevention on the
RP side. azp (when present) is the canonical “authorized party”;
aud may be array (the engine surfaces only the first element to
the hint pipeline); kid identifies the signing key.
Field repurpose: stores azp_hint in
Self::client_id_hint (the SDK-shaped “authorized party”
shares semantic with access-token’s client_id); pushes
aud_hint into metadata under the key "aud_hint". Dashboard
pivots on the access-token side use client_id_hint directly;
id_token pivots use the same field plus the aud_hint metadata
entry.
Production caller: [crate::oidc::PasIdTokenVerifier::emit_failure].
Sourcepub fn rate_limit_key(&self) -> RateLimitKey
pub fn rate_limit_key(&self) -> RateLimitKey
Per-bucket rate-limit key. By default 1:1 with source_id.
Composing once at construction keeps this O(1).
Trait Implementations§
Source§impl Clone for AuditEvent
impl Clone for AuditEvent
Source§fn clone(&self) -> AuditEvent
fn clone(&self) -> AuditEvent
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more