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:| Level | Interface | Use Case |
|---|---|---|
| Role-Permission | BedrockRolePermission.condition | ”Editors can only edit draft documents” |
| Scope Override | BedrockScopeRolePermissionOverride.condition | ”In production, only during business hours” |
| Resource Policy | BedrockResourcePolicy.subjectCondition | ”Only finance team can access this report” |
| Resource Policy | BedrockResourcePolicy.contextCondition | ”Only from approved IP ranges” |
JSON Logic Basics
JSON Logic uses a simple JSON structure to express conditions:Common Operators
| Operator | Description | Example |
|---|---|---|
== | Equals | {"==": [{"var": "subject.type"}, "admin"]} |
!= | Not equals | {"!=": [{"var": "resource.status"}, "archived"]} |
>, >=, <, <= | Comparisons | {">=": [{"var": "subject.level"}, 3]} |
in | Value in array | {"in": [{"var": "subject.dept"}, ["finance", "accounting"]]} |
and | All conditions true | {"and": [cond1, cond2]} |
or | Any condition true | {"or": [cond1, cond2]} |
! | Negation | {"!": [condition]} |
if | Conditional | {"if": [cond, then, else]} |
The var Operator
Use var to access values from the evaluation context:
Conditional Role-Permissions
Add conditions when assigning permissions to roles:Conditional Scope Overrides
Add conditions to scope-level overrides:Context Variables
The evaluation context provides these variables:Subject Variables
| Variable | Description |
|---|---|
subject.id | Subject ID |
subject.type | Subject type (user, agent, service) |
subject.externalId | External system ID |
subject.meta.* | Custom metadata fields |
Resource Variables
| Variable | Description |
|---|---|
resource.id | Resource ID |
resource.type | Resource type |
resource.ownerId | Owner subject ID |
resource.ownerScopeId | Owner scope ID |
resource.meta.* | Custom metadata fields |
resource.tags.* | Tag assignments |
Context Variables
| Variable | Description |
|---|---|
context.time.hour | Current hour (0-23) |
context.time.dayOfWeek | Day of week (0=Sun, 6=Sat) |
context.ip | Request IP address |
context.* | Any custom context you provide |
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.