Liking cljdoc? Tell your friends :D

stroopwafel.pdp.core

Policy Decision Point — the bridge between crypto and logic.

Verifies signed chains (signet), extracts assertions as facts, and feeds them to the Datalog engine (stroopwafel) for a decision.

Usage: (-> (context) (add-chain signed-chain {:trust-root root-kid}) (add-chain idp-chain {:trust-root idp-kid}) (add-facts [[:current-time (System/currentTimeMillis)] [:requested-effect :read]]) (decide :rules [...] :policies [{:kind :allow :query [...]}])) ;; → {:allowed? true/false}

Policy Decision Point — the bridge between crypto and logic.

Verifies signed chains (signet), extracts assertions as facts,
and feeds them to the Datalog engine (stroopwafel) for a decision.

Usage:
  (-> (context)
      (add-chain signed-chain {:trust-root root-kid})
      (add-chain idp-chain {:trust-root idp-kid})
      (add-facts [[:current-time (System/currentTimeMillis)]
                  [:requested-effect :read]])
      (decide
        :rules [...]
        :policies [{:kind :allow :query [...]}]))
  ;; → {:allowed? true/false}
raw docstring

add-chainclj

(add-chain ctx token {:keys [trust-root]})

Verify a signed chain and add its facts to the context.

The chain is verified via signet.chain/verify. If verification fails, the error is recorded. If it passes, each block's facts, rules, and checks are extracted and added.

Arguments:

  • ctx : PDP context
  • token : signet chain (from signet.chain/extend + close)
  • opts : {:trust-root <kid URN>} — expected root authority

Returns updated context.

Verify a signed chain and add its facts to the context.

The chain is verified via signet.chain/verify. If verification
fails, the error is recorded. If it passes, each block's
facts, rules, and checks are extracted and added.

Arguments:
  - ctx   : PDP context
  - token : signet chain (from signet.chain/extend + close)
  - opts  : {:trust-root <kid URN>} — expected root authority

Returns updated context.
raw docstring

add-factsclj

(add-facts ctx facts)

Add local context facts (current time, request metadata, etc.).

These are not signed — they represent the service's own assertions about the current request. Trusted because they come from the service itself.

Arguments:

  • ctx : PDP context
  • facts : vector of fact tuples

Returns updated context.

Add local context facts (current time, request metadata, etc.).

These are not signed — they represent the service's own assertions
about the current request. Trusted because they come from the
service itself.

Arguments:
  - ctx   : PDP context
  - facts : vector of fact tuples

Returns updated context.
raw docstring

add-rulesclj

(add-rules ctx rules)

Add rules to the context (e.g., template rules for assertion types).

Arguments:

  • ctx : PDP context
  • rules : vector of rule maps

Returns updated context.

Add rules to the context (e.g., template rules for assertion types).

Arguments:
  - ctx   : PDP context
  - rules : vector of rule maps

Returns updated context.
raw docstring

add-signed-envelopeclj

(add-signed-envelope ctx envelope)

Verify a signed envelope and add the signer as a fact.

Used for requester-bound tokens where the agent signs each request. The verified signer's kid is added as a fact for Datalog joins.

Arguments:

  • ctx : PDP context
  • envelope : signet signed envelope (from signet.sign/sign-edn)

Returns updated context with [:request-verified-signer <kid>] fact.

Verify a signed envelope and add the signer as a fact.

Used for requester-bound tokens where the agent signs each request.
The verified signer's kid is added as a fact for Datalog joins.

Arguments:
  - ctx      : PDP context
  - envelope : signet signed envelope (from signet.sign/sign-edn)

Returns updated context with [:request-verified-signer <kid>] fact.
raw docstring

contextclj

(context)

Create an empty PDP context.

The context accumulates verified facts from signed chains and local assertions. When decide is called, all accumulated facts are evaluated by the Datalog engine.

Create an empty PDP context.

The context accumulates verified facts from signed chains and
local assertions. When decide is called, all accumulated facts
are evaluated by the Datalog engine.
raw docstring

decideclj

(decide ctx
        &
        {:keys [rules checks policies explain? trusted-external-keys limits]
         :as opts})

Make a policy decision based on the accumulated context.

All verified facts from chains and local context are assembled into a token structure and evaluated by the stroopwafel Datalog engine.

If any chain or envelope failed verification, authorization is denied immediately.

Arguments:

  • ctx : PDP context
  • keyword args: :rules — additional authorizer rules :checks — additional authorizer checks :policies — ordered allow/deny policies (first match wins) :explain? — include proof tree in result :trusted-external-keys — vector of kid URNs for trusted third-party block signers :limits — engine fixpoint limits (:max-iterations, :max-facts)

Returns: {:allowed? boolean} or {:allowed? false :errors [...]} (context errors) or {:allowed? false :error {:type :limit-exceeded ...}} (the engine reached a limit before its fixpoint) plus :warnings from the engine when it has any, e.g. [{:type :no-policies}] (no policies: the engine denies, since only a matching :allow allows) or [{:type :arity-mismatch ...}].

Unknown options throw (:stroopwafel/error :unknown-keys): a typo such as :check would otherwise silently drop the checks.

Make a policy decision based on the accumulated context.

All verified facts from chains and local context are assembled
into a token structure and evaluated by the stroopwafel Datalog
engine.

If any chain or envelope failed verification, authorization is
denied immediately.

Arguments:
  - ctx : PDP context
  - keyword args:
      :rules    — additional authorizer rules
      :checks   — additional authorizer checks
      :policies — ordered allow/deny policies (first match wins)
      :explain? — include proof tree in result
      :trusted-external-keys — vector of kid URNs for trusted
                               third-party block signers
      :limits   — engine fixpoint limits (:max-iterations, :max-facts)

Returns:
  {:allowed? boolean}
  or {:allowed? false :errors [...]}   (context errors)
  or {:allowed? false :error {:type :limit-exceeded ...}}
     (the engine reached a limit before its fixpoint)
  plus :warnings from the engine when it has any, e.g.
  [{:type :no-policies}] (no policies: the engine denies, since only a
  matching :allow allows) or [{:type :arity-mismatch ...}].

Unknown options throw (:stroopwafel/error :unknown-keys): a typo such as
:check would otherwise silently drop the checks.
raw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close