When your application asks “Can this subject do this action?”, Bedrock’s evaluation engine processes the request through a series of steps to produce a decision.
Every permission check requires an evaluation input:
Copy
interface BedrockEvaluateInput { actor: BedrockSubjectRef; // Who is performing the action onBehalfOf?: BedrockSubjectRef; // Optional: acting on behalf of another subject scopeId: string; // Where the action is happening action: string; // What action is being performed resource?: BedrockResourceRef; // What resource is being accessed context?: Record<string, unknown>; // Additional context for conditions includeResourceTags?: boolean; // Auto-load resource tags (default: true)}
The engine evaluates permissions in a specific order, with earlier steps taking precedence:
Copy
┌─────────────────────────────────────────────────────────────┐│ 1. RESOURCE POLICIES (highest priority) ││ ├── Get policies targeting the specific resource ││ ├── Get collections matching the resource ││ ├── Get policies targeting those collections ││ ├── Sort by priority (highest first) ││ ├── Evaluate subject and context conditions ││ └── If a policy matches → return allow/deny immediately │└─────────────────────────────────────────────────────────────┘ │ ▼┌─────────────────────────────────────────────────────────────┐│ 2. RESOURCE HIERARCHY INHERITANCE ││ ├── If resource has parents with cascade: inherit ││ ├── Check ancestor permissions recursively ││ └── Return if any ancestor grants permission │└─────────────────────────────────────────────────────────────┘ │ ▼┌─────────────────────────────────────────────────────────────┐│ 3. ROLE-BASED PERMISSIONS ││ ├── Resolve actor → get memberships in scope hierarchy ││ ├── Collect role assignments for memberships ││ ├── Gather permissions from assigned roles ││ ├── Apply scope overrides (role, permission, role-perm) ││ ├── Match action & resource pattern ││ ├── Evaluate conditional permissions (JSON Logic) ││ └── Return decision with matching permissions │└─────────────────────────────────────────────────────────────┘
Resource policies are evaluated first and can short-circuit the entire evaluation.
This makes them ideal for explicit allow/deny rules on sensitive resources.
interface BedrockDecision { allowed: boolean; // Final result matches: BedrockPermissionMatch[]; // Permissions that contributed explanation?: string; // Human-readable reason // Policy evaluation (new) evaluatedPolicy?: BedrockResourcePolicy; // Policy that decided (if any) decidedByPolicy?: boolean; // Was decision made by a policy? // Resource context evaluatedResource?: BedrockResource; // Resolved resource evaluatedResourceType?: BedrockResourceType; inheritedFrom?: string; // Ancestor resource ID if inherited resourceTags?: BedrockTag[]; // Tags on the resource // Actor context evaluatedActor?: BedrockSubjectRef; // Echo of actor evaluatedOnBehalfOf?: BedrockSubjectRef; // Echo of principal usedDelegation?: boolean; // Was onBehalfOf used? delegationId?: string; // Delegation reference if applicable evaluatedContext?: Record<string, unknown>; // Final context used}