Policy¶
Build and evaluate attestation policies.
Decision
dataclass
¶
Result of evaluating a policy against a context.
Supports boolean evaluation: if decision: is equivalent to if decision.allowed.
PolicyBuilder
¶
Fluent builder for Auths access policies.
Examples:
policy = PolicyBuilder.standard("sign_commit").build()
policy = (PolicyBuilder()
.not_revoked()
.not_expired()
.require_capability("sign_commit")
.require_issuer("did:keri:EOrg123")
.build())
standard
classmethod
¶
standard(capability: str) -> PolicyBuilder
The "80% policy": not revoked, not expired, requires one capability.
from_json
classmethod
¶
from_json(json_str: str) -> PolicyBuilder
Reconstruct a PolicyBuilder from a JSON policy expression.
Parameters:
-
json_str(str) –JSON string from
to_json()or config files.
Returns:
-
PolicyBuilder–A new PolicyBuilder with the parsed predicates.
Examples:
available_predicates
classmethod
¶
Return the list of available predicate method names.
available_presets
classmethod
¶
Return the list of available preset policy names.
any_of
classmethod
¶
any_of(*builders: PolicyBuilder) -> PolicyBuilder
Create a policy that passes if ANY of the given policies pass.
expires_after
¶
expires_after(seconds: int) -> PolicyBuilder
Require at least seconds of remaining validity.
issued_within
¶
issued_within(seconds: int) -> PolicyBuilder
Require the attestation was issued within seconds ago.
or_policy
¶
or_policy(other: PolicyBuilder) -> PolicyBuilder
Combine with another policy using OR logic.