Skip to main content

evaluate_grant

Function evaluate_grant 

Source
pub fn evaluate_grant<V: UcanVerifier + ?Sized>(
    grant: &Ucan,
    verifier: &V,
    now: u64,
    request: &GrantRequest,
    subject: Option<&SecurityContext>,
    sender_bound: bool,
) -> Result<GrantDecision, GrantError>
Expand description

Evaluate a UCAN grant request: the single fail-closed S6 path.

Inputs:

  • grant: the presented subset-UCAN (a delegation chain whose root capabilities are the ceiling for this request).
  • verifier: the S5 UcanVerifier (trust store resolving each issuer’s anchored ML-DSA-65 key). Signatures are verified under the hybrid policy.
  • now: the single trusted clock (unix seconds), threaded unchanged into every chain link by S5 — never read from the token.
  • request: what the principal is asking to do now (the subset).
  • subject: the principal’s verified security context (S1 clearance + assurance, clamped to verified key material). None ⇒ unlabeled ⇒ deny.
  • sender_bound: whether a DPoP proof was supplied and verified by the caller. ZSP requires sender-binding; false ⇒ deny.

Gates, in order (all fail-closed; the first failure wins):

  1. Sender-binding required (ZSP) — no bearer tokens from a grant.
  2. Non-empty grant — an empty grant mints nothing.
  3. Labeled subject — S1: unlabeled subject ⇒ deny (no default clearance).
  4. Labeled object — S1: unlabeled object ⇒ deny.
  5. MAC clearance floor — subject.clearance ⊒ object_label.
  6. UCAN chain valid — S5 validate (signatures + attenuation + temporal).
  7. Ceiling-subset — authorize_at(grant.capabilities(), grant.window, request, now) permits. Deny ⇒ over-ceiling ⇒ Escalate (not auto-mint).

Order rationale: the cheap structural/label gates run before the cryptographic chain walk, so a malformed or uncleared request is rejected without spending the signature-verification budget. The chain is validated before the ceiling check so an invalid chain can never reach authorize.