Policy Engine
The policy engine provides rule-based access control with RBAC, pattern matching on DIDs, actions, and resources.
Rules
Rules match requests by subject (DID pattern), action, and resource, with priorities for conflict resolution.
from trusthub import PolicyRule, PolicySet, PolicyEngine
from trusthub.constants import PolicyEffect
rule = PolicyRule(
name="allow_search",
subject="role:analyst",
action="search",
resource="*",
effect=PolicyEffect.ALLOW,
priority=100,
)Subject Patterns
did:trusthub:acme:abc...— Exact DID matchdid:trusthub:acme:*— Org-level wildcardrole:admin— Role-based matchentity:agent— Entity type match