pub enum PolicyDecision {
Allow,
Deny {
reason: String,
},
Mutate {
headers: Vec<(String, String)>,
body: Option<Vec<u8>>,
},
}Expand description
Outcome of a single policy evaluation.
See the module docs for why this is a flat enum instead of
Result<(), String>. The TL;DR: callers need to branch on three
normal outcomes (Allow / Deny / Mutate), and the host must not
conflate “policy said no” with “engine exploded”.
Variants§
Allow
Proceed with the request, no changes. The default for 99% of successful policy evaluations.
Deny
Refuse the request. The host MUST forward reason to the
structured log and should surface it to the client when the
engine is trusted (the Cedar and CEL refs produce reasons safe
for 403 bodies — custom engines must document their own guarantees).
Fields
Mutate
Proceed, but apply response-side obligations on the way out.
The host applies these after the handler runs — header
injection before headers flush, body substitution before the
response hits the wire. Both fields are optional; a Mutate with
neither headers nor body is legal (a no-op, but engines may emit
it during composition) and the host treats it as Allow.
Implementations§
Source§impl PolicyDecision
impl PolicyDecision
Sourcepub fn deny(reason: impl Into<String>) -> Self
pub fn deny(reason: impl Into<String>) -> Self
Convenience: a Deny with the given reason, owning the string.
Sourcepub fn is_allowed(&self) -> bool
pub fn is_allowed(&self) -> bool
true for Allow and for Mutate (both proceed). false for
Deny. Useful for middleware that only needs the gate decision
and handles mutation elsewhere.
Trait Implementations§
Source§impl Clone for PolicyDecision
impl Clone for PolicyDecision
Source§fn clone(&self) -> PolicyDecision
fn clone(&self) -> PolicyDecision
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more