SPKI/SDSI-shaped PDP: context builder, assertion ingestion, the pre-filter pipeline, and decide.
Usage: (-> (context) (add-trust-roots #{authority-kid}) (with-templates tmpl/standard) (add-assertions signed-block) (add-facts [[:current-time (System/currentTimeMillis)]]) (decide :policies [{:kind :allow :query [[:can "alice" :read "/data"]]}]))
Phase 2 scope: passes 1–5 of the pre-filter (sig → trust → temporal → revocation → expand). Trust is a flat primordial set — delegation closure is Phase 3. The pipeline is otherwise complete end-to-end.
See docs/assertion-api-proposal.md for the full design.
SPKI/SDSI-shaped PDP: context builder, assertion ingestion, the
pre-filter pipeline, and decide.
Usage:
(-> (context)
(add-trust-roots #{authority-kid})
(with-templates tmpl/standard)
(add-assertions signed-block)
(add-facts [[:current-time (System/currentTimeMillis)]])
(decide :policies [{:kind :allow
:query [[:can "alice" :read "/data"]]}]))
Phase 2 scope: passes 1–5 of the pre-filter (sig → trust → temporal
→ revocation → expand). Trust is a flat primordial set — delegation
closure is Phase 3. The pipeline is otherwise complete end-to-end.
See docs/assertion-api-proposal.md for the full design.Alias for add-assertions — single-block convenience.
Alias for add-assertions — single-block convenience.
(add-assertions ctx signed-block)Add a signed assertion block. Verification is lazy — the block is checked when decide runs, not at add time, so context building stays cheap.
Add a signed assertion block. Verification is lazy — the block is checked when decide runs, not at add time, so context building stays cheap.
(add-checks ctx checks)Add user-supplied Datalog checks to the authorizer scope.
Add user-supplied Datalog checks to the authorizer scope.
(add-facts ctx facts)Add injected service-local facts (current time, request state, account balances, etc.). These are unsigned and implicitly trusted — they come from the service itself. Kept separate from assertion-derived facts.
Add injected service-local facts (current time, request state, account balances, etc.). These are unsigned and implicitly trusted — they come from the service itself. Kept separate from assertion-derived facts.
(add-rules ctx rules)Add user-supplied Datalog rules to the authorizer scope.
Add user-supplied Datalog rules to the authorizer scope.
(add-trust-roots ctx roots)Register primordial trust-root sayers.
Accepts:
Primordial trust is a floor: delegation can only raise a primordial root's effective scope (pinned decision §11 #6), never narrow it. Multiple calls accumulate.
The context stores trust-roots as either a set of strings (simple case) or a map (scoped case); both forms are accepted by the trust closure at decide time.
Register primordial trust-root sayers.
Accepts:
- a kid URN string — trusted for :all assertion types, forever
- a set/sequence of kid URN strings — same
- a map {kid → {:for-types <:all or set> :not-after <epoch-ms or nil>}}
— scoped primordial trust
Primordial trust is a floor: delegation can only raise a primordial
root's effective scope (pinned decision §11 #6), never narrow it.
Multiple calls accumulate.
The context stores trust-roots as either a set of strings (simple
case) or a map (scoped case); both forms are accepted by the trust
closure at decide time.(context)(context opts)Create an empty SPKI PDP context.
Options: :clock-skew-ms — symmetric clock skew tolerance (default 5000) :current-time-fn — zero-arg fn returning epoch-ms (default #(System/currentTimeMillis))
Create an empty SPKI PDP context.
Options:
:clock-skew-ms — symmetric clock skew tolerance (default 5000)
:current-time-fn — zero-arg fn returning epoch-ms
(default #(System/currentTimeMillis))(decide ctx
&
{:keys [policies rules checks explain? max-block-ttl-ms limits]
:as opts})Run the pre-filter pipeline and evaluate the policy.
Options: :policies — ordered allow/deny policies (first match wins) :rules — extra authorizer rules (in addition to templates) :checks — extra authorizer checks :explain? — include proof tree + rejected assertions :max-block-ttl-ms — verifier cap on block :not-after (§5.2) :limits — engine fixpoint limits (:max-iterations, :max-facts)
Returns: {:allowed? boolean} or {:allowed? boolean :explain ... :rejected ...} (explain? mode) 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.
Run the pre-filter pipeline and evaluate the policy.
Options:
:policies — ordered allow/deny policies (first match wins)
:rules — extra authorizer rules (in addition to templates)
:checks — extra authorizer checks
:explain? — include proof tree + rejected assertions
:max-block-ttl-ms — verifier cap on block :not-after (§5.2)
:limits — engine fixpoint limits (:max-iterations, :max-facts)
Returns:
{:allowed? boolean}
or {:allowed? boolean :explain ... :rejected ...} (explain? mode)
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.(with-revocation-source ctx f)Register a function that returns {:ids #{...} :keys #{...} :subjects #{...}} representing live out-of-band revocations. Called once per decide. In-band :revocation assertions inside blocks are always collected regardless of whether this is set.
Register a function that returns {:ids #{...} :keys #{...} :subjects #{...}}
representing live out-of-band revocations. Called once per decide.
In-band :revocation assertions inside blocks are always collected
regardless of whether this is set.(with-templates ctx templates)Register derivation templates. These are Datalog rules that unpack assertion tuples into clean named predicates (e.g., [:can ?s ?a ?r] from a :capability assertion). Added to the authorizer rules at decide time.
Register derivation templates. These are Datalog rules that unpack assertion tuples into clean named predicates (e.g., [:can ?s ?a ?r] from a :capability assertion). Added to the authorizer rules at decide time.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |