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 resolvessubject 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 undersubject:
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 andincludeResourceTags is true (the
default):
Time (trusted clock)
The engine injects the current time from a trusted server clock at the top level. Anytime, 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 incontext 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:- No condition → Permission always applies
- Condition evaluates to
true→ Permission applies - Condition evaluates to
false→ Permission does not apply - Condition errors → Permission does not apply (fail-closed)
Debugging Conditions
The decision output includes condition evaluation details:Best Practices
Keep conditions simple
Keep conditions simple
Complex nested conditions are hard to debug. Break them into multiple permissions if needed.
Test conditions thoroughly
Test conditions thoroughly
Create test cases for all condition branches before deploying.
Use meaningful variable names
Use meaningful variable names
Structure your metadata with clear, consistent naming.
Document your conditions
Document your conditions
Add descriptions to permissions explaining what the condition does.
Fail closed
Fail closed
If a condition can’t be evaluated (missing data), access is denied by default.
Related Concepts
Resource Policies
Fine-grained policies with subject and context conditions
Evaluation
How conditions are evaluated in the permission check flow