Skip to main content

What are Resource Policies?

Resource Policies provide fine-grained access control at the resource level. Unlike role-based permissions that apply broadly, policies target specific resources or collections with precise allow/deny rules. Policies are evaluated before role-based permissions, giving you a powerful override mechanism.

Policy Properties

A resource policy has no name or description field. If you send them they are silently dropped (don’t rely on them). Express intent with priority, target, and conditions.

Policy Targets

Target a Specific Resource

Target a Collection

Creating Policies

Allow Policy on a Resource

Deny Policy on a Collection

Policy with Context Condition

Policy Effects

Allow

Grants access if the policy matches:

Deny

Blocks access if the policy matches. Deny policies typically have higher priority:

Priority and Evaluation Order

Policies resolve by priority group, not first-match:
  1. All matching policies (action matches, temporal window active, subject/context conditions pass) are collected.
  2. Only the highest-priority group among the matches decides.
  3. Within that group, deny beats allow (deny-overrides)—it is not “first match wins”.
  4. If no policy matches, role-based permissions are checked.
A lower-priority deny does not override a higher-priority allow: priority selects the group, and deny wins only within the winning group.

Subject Conditions

Match based on the actor making the request:

Context Conditions

Match based on request context:

Combined Conditions

Use both subject and context conditions:

Evaluation Flow

When BedrockEngine.evaluate() is called:

Decision Output

When a policy decides the outcome:

Common Patterns

Owner-Only Access

resource.ownerId is not exposed in the condition context (see the roadmap), so a policy condition can’t compare it to the actor. For owner-based access today, use a resource-ownership grant (owns(subject, resource, role)) instead of a policy, or surface the owner’s subject id as a resource tag and match tags.<identifier>.

Deny All Except Admins

Temporary Access Window

Geographic Restrictions

Best Practices

Prefer allow policies with specific conditions. Deny policies can be hard to debug.
Use a consistent priority scheme. Example: deny=100+, allow=50, default=0.
Verify both allow and deny cases before deploying.
Use clear names and descriptions explaining why the policy exists.
Policies on collections are more maintainable than many individual resource policies.

Resource Collections

Define dynamic resource groups for policies

Conditional Permissions

JSON Logic conditions on role-based permissions

Evaluation

How policies fit into the evaluation flow