Skip to main content

What are Conditional Permissions?

Conditional permissions allow you to add dynamic rules to your access control using JSON Logic expressions. Instead of simple allow/deny, you can create permissions that evaluate based on:
  • Subject attributes (department, clearance level, role metadata)
  • Resource properties (owner, status, tags)
  • Request context (time, IP address, device type)
  • Custom business logic

Where Conditions Apply

Conditions can be added at multiple levels:

JSON Logic Basics

JSON Logic uses a simple JSON structure to express conditions:

Common Operators

The var Operator

Use var to access values from the evaluation context:

Conditional Role-Permissions

Add conditions when assigning permissions to roles:
The resource object does not expose an owner subject id. To match a resource’s owner against the acting subject, surface the owner id as a resource tag (read via tags.<identifier>) or pass it in your own context. resource.ownerScopeId identifies the owning scope, not a subject.

Conditional Scope Overrides

Add conditions to scope-level overrides:

Context Variables

The evaluation context provides these variables. The engine resolves subject from the actor, and—when a resource is supplied—resource, tags, and tagList. These resolved values overwrite any same-named keys you pass in context.

Subject Variables

The full resolved subject is exposed under subject:

Resource Variables

Available only when the evaluation includes a resource. These are the only resource fields exposed:
There is no resource.meta or resource.ownerId, and arbitrary resource columns are not auto-exposed. To use custom resource attributes (owner subject, amount, status, classification, etc.) in a condition, surface them as tags (tags.* / tagList) or pass them yourself in context.

Tag Variables

Loaded when a resource is resolved and includeResourceTags is true (the default):

Time (trusted clock)

The engine injects the current time from a trusted server clock at the top level. Any time, now, or nowMs you pass in context is ignored, so a caller cannot forge the time to slip past a time-based condition:

Your Context

Any other keys you pass in context are spread at the top level (not under a context. prefix). The resolved subject, resource, tags, and tagList overwrite same-named keys:

Common Patterns

Department-Based Access

Clearance Level

Owner-Only Access

Business Hours Only

IP Allowlist

Combined Conditions

Evaluation Behavior

When a permission has a condition:
  1. No condition → Permission always applies
  2. Condition evaluates to true → Permission applies
  3. Condition evaluates to false → Permission does not apply
  4. Condition errors → Permission does not apply (fail-closed)

Debugging Conditions

The decision output includes condition evaluation details:

Best Practices

Complex nested conditions are hard to debug. Break them into multiple permissions if needed.
Create test cases for all condition branches before deploying.
Structure your metadata with clear, consistent naming.
Add descriptions to permissions explaining what the condition does.
If a condition can’t be evaluated (missing data), access is denied by default.

Resource Policies

Fine-grained policies with subject and context conditions

Evaluation

How conditions are evaluated in the permission check flow