Authorization Guide
Idenplane provides a flexible authorization system based on Attribute-Based Access Control (ABAC) policies. This guide covers role-based access control (RBAC), policy creation, condition types, and policy evaluation.
Overview
Idenplane's authorization system combines RBAC with ABAC for fine-grained access control:
| Approach | Description | Use Case |
|---|---|---|
| RBAC | Role-based permissions assigned to users | Basic access control |
| ABAC Policies | Attribute-based rules with conditions | Complex, dynamic access decisions |
Authorization Flow
DENY-Override Algorithm
Idenplane uses a DENY-override algorithm:
- The enabled policies that apply to the request's client are kept (see Client-Scoped Policies)
- They are sorted by priority (highest first)
- Each policy is evaluated against the request
- If any DENY policy matches → final decision is DENY
- If at least one ALLOW policy matches → final decision is ALLOW
- If no policy matches → default DENY
A policy that cannot be evaluated fails closed: a DENY matches, an ALLOW never does (see Validation and fail-closed evaluation).
Idenplane defaults to DENY when no policy matches. This ensures secure access control by default.
Roles and Permissions
Roles are the foundation of RBAC in Idenplane. Users can be assigned multiple roles, directly or through groups. Roles do not inherit from each other: there are no composite roles.
Assigning Roles to Users
# Assign role to user via Admin API
curl -X POST "http://localhost:3000/admin/realms/my-realm/users/user-123/role-mappings/realm" \
-H "Authorization: Bearer ${ADMIN_TOKEN}" \
-H "Content-Type: application/json" \
-d '{"roleNames": ["admin", "moderator"]}'
Role-Based Permissions
| Role | Permissions |
|---|---|
admin | Full access to all resources |
moderator | Manage content, view reports |
user | Read/write own resources |
guest | Read-only public resources |
ABAC Policies
ABAC policies in Idenplane are defined as JSON documents with conditions on four categories:
Policy Structure
{
"id": "policy-uuid-123",
"name": "allow-admins-to-read-reports",
"description": "Allows admin-role users to read report resources",
"enabled": true,
"effect": "ALLOW",
"priority": 10,
"logic": "AND",
"clientId": null,
"subjectConditions": [
{ "field": "subject.roles", "operator": "contains", "value": "admin" }
],
"resourceConditions": [
{ "field": "resource.type", "operator": "equals", "value": "report" }
],
"actionConditions": [
{ "field": "action", "operator": "in", "value": ["read", "list"] }
]
}
Policy Fields
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Unique policy name within realm |
description | string | No | Human-readable description |
enabled | boolean | No | Whether policy is active (default: true) |
effect | string | No | "ALLOW" or "DENY" (default: "ALLOW") |
priority | integer | No | Higher = evaluated first (default: 0) |
logic | string | No | "AND" or "OR" for conditions (default: "AND") |
clientId | string | No | Scope the policy to one client (its clientId). It then applies only to evaluations that pass the same clientId |
subjectConditions | array | No | Conditions on the subject (user) |
resourceConditions | array | No | Conditions on the resource |
actionConditions | array | No | Conditions on the action |
environmentConditions | array | No | Conditions on environment (IP, time) |
Condition Operators
Idenplane supports the following condition operators. Each condition is { "field", "operator", "value" }; the operator name is case-sensitive, and the value must be of the kind the operator needs. Anything else is refused with a 400 when the policy is saved.
Comparison Operators
| Operator | Description | value |
|---|---|---|
equals | Exact match | a string, number, boolean or null |
notEquals | Not equal | a string, number, boolean or null |
contains | The string contains the value, or the array has it as an element | a string, number, boolean or null |
in | The field's value is one of the array's elements | an array, e.g. ["read", "write"] |
notIn | The field's value is none of them | an array, e.g. ["delete"] |
Numeric Operators
| Operator | Description | value |
|---|---|---|
greaterThan | Numeric comparison, e.g. level > 5 | a number, or a string holding one |
lessThan | Numeric comparison, e.g. count < 100 | a number, or a string holding one |
Pattern Operators
| Operator | Description | value |
|---|---|---|
matches | Regex match, e.g. email matches ^[^@]+@company\.com$ | a JavaScript regular expression of at most 256 characters, without backreferences or nested repetition (see below) |
ipInRange | The IP address is in the range | an IPv4 or IPv6 address, or a CIDR block: 10.0.0.0/8, 2001:db8::/32, 203.0.113.7 |
ipInRange handles IPv4 and IPv6. An IPv4-mapped IPv6 address (::ffff:10.1.2.3, which is how a dual-stack server reports an IPv4 client) matches the IPv4 range it belongs to, so a rule on 10.0.0.0/8 applies whichever form your application passes. An IPv4 address never matches an IPv6 range, and the other way round.
A condition on a field the request does not carry is false (for example ipInRange with no environment.ip). A field that is present but is not an IP address makes an ipInRange condition fail closed, like an invalid condition.
Validation and fail-closed evaluation
Every condition is checked when a policy is created or updated (and when a realm is imported): an unknown operator such as equal or contain, a missing field or value, an array for equals, in without an array, a non-numeric bound, an invalid regular expression or an invalid CIDR is refused with a 400 that names the condition, for example subjectConditions[1]: unknown operator "contain" (expected one of: ...).
Regular expressions (matches). The pattern runs against values from the request, so a pattern with catastrophic backtracking would let any caller of the evaluate endpoint stall the server (ReDoS). A pattern is accepted only if it is at most 256 characters, uses no backreferences (\1, \k<name>), and never repeats a group that itself repeats or alternates: (a+)+, (a*)*, (a|b)* and (\w+\s?)* are refused; (ab)+, ^(read|write): and [a-z]+@ are fine. A value longer than 2,048 characters is not tested: the condition is indeterminate and fails closed.
A stored policy that still cannot be evaluated (one saved by a version before 0.11.0, or written to the database directly) fails closed:
- a DENY policy with such a condition matches, whatever its other conditions say: it denies every request it applies to;
- an ALLOW policy with such a condition never matches;
- an unknown
effect(anything butALLOWandDENY) is treated asDENY, and an unknownlogicmakes the policy fail closed too.
The evaluation result says so ("indeterminate": true on the policy and on the condition, and a reason ending in "fails closed"), and the server logs a warning naming the policy. GET /admin/upgrade/health lists every such policy in the invalid_authorization_policies warning, as realm/policy (EFFECT): path: problem. Fix or delete them.
Before 0.11.0 conditions were not validated, and a condition that could not be evaluated was simply false. A DENY with a typo in an operator therefore never denied. See the CHANGELOG for the upgrade notes.
Condition Field Paths
Conditions use dot-notation paths:
| Path | Description | Example Value |
|---|---|---|
subject.userId | User ID | "user-uuid-123" |
subject.roles | User roles array | ["admin", "user"] |
subject.groups | User groups array | ["engineering"] |
subject.attributes | Custom attributes | { "department": "eng" } |
resource.type | Resource type | "report" |
resource.id | Resource ID | "resource-uuid" |
resource.ownerId | Resource owner | "user-uuid-123" |
resource.attributes | Resource attributes | { "classification": "secret" } |
action | Action name | "read" |
environment.ip | Client IP address | "192.168.1.1" |
environment.time | Request timestamp | "2026-03-24T10:00:00Z" |
Creating Policies
Create Policy via API
curl -X POST "http://localhost:3000/admin/realms/my-realm/policies" \
-H "Authorization: Bearer ${ADMIN_TOKEN}" \
-H "Content-Type: application/json" \
-d '{
"name": "allow-admins-all-access",
"description": "Allows admin users full access",
"effect": "ALLOW",
"priority": 100,
"subjectConditions": [
{ "field": "subject.roles", "operator": "contains", "value": "admin" }
]
}'
Response:
{
"id": "policy-uuid-new-123",
"name": "allow-admins-all-access",
"description": "Allows admin users full access",
"enabled": true,
"effect": "ALLOW",
"priority": 100,
"logic": "AND",
"clientId": null,
"subjectConditions": [
{ "field": "subject.roles", "operator": "contains", "value": "admin" }
],
"resourceConditions": null,
"actionConditions": null,
"environmentConditions": null,
"createdAt": "2026-05-10T12:00:00.000Z",
"updatedAt": "2026-05-10T12:00:00.000Z"
}
Policy Examples
Allow Admins Read Access
{
"name": "admins-read-access",
"description": "Allow admins to read all resources",
"effect": "ALLOW",
"subjectConditions": [
{ "field": "subject.roles", "operator": "contains", "value": "admin" }
],
"actionConditions": [
{ "field": "action", "operator": "in", "value": ["read", "list"] }
]
}
Deny Guest Access to Confidential Resources
{
"name": "deny-guests-confidential",
"description": "Deny guest users access to confidential resources",
"effect": "DENY",
"priority": 200,
"subjectConditions": [
{ "field": "subject.roles", "operator": "contains", "value": "guest" }
],
"resourceConditions": [
{ "field": "resource.attributes.classification", "operator": "equals", "value": "confidential" }
]
}
IP Range Restriction
{
"name": "internal-network-only",
"description": "Allow access only from internal network",
"effect": "ALLOW",
"logic": "OR",
"environmentConditions": [
{ "field": "environment.ip", "operator": "ipInRange", "value": "10.0.0.0/8" },
{ "field": "environment.ip", "operator": "ipInRange", "value": "172.16.0.0/12" },
{ "field": "environment.ip", "operator": "ipInRange", "value": "192.168.0.0/16" }
]
}
logic defaults to AND, which would require the address to be in all three ranges at once. ipInRange handles IPv4 only.
Conditions compare a field with a fixed value; a condition cannot compare two fields of the request, such as resource.ownerId with subject.userId. Check ownership in your application.
Group-Based Access
{
"name": "engineering-access",
"description": "Allow engineering group access to engineering resources",
"effect": "ALLOW",
"subjectConditions": [
{ "field": "subject.groups", "operator": "contains", "value": "engineering" }
],
"resourceConditions": [
{ "field": "resource.attributes.department", "operator": "equals", "value": "engineering" }
]
}
Evaluating Policies
Evaluate All Policies
curl -X POST "http://localhost:3000/admin/realms/my-realm/policies/evaluate" \
-H "Authorization: Bearer ${ADMIN_TOKEN}" \
-H "Content-Type: application/json" \
-d '{
"subject": {
"userId": "user-uuid-123",
"roles": ["admin", "user"],
"groups": ["engineering"],
"attributes": { "department": "engineering" }
},
"resource": {
"type": "report",
"id": "report-uuid-456",
"attributes": { "classification": "internal" }
},
"action": "read",
"environment": {
"ip": "10.1.2.3"
}
}'
Response:
{
"decision": "ALLOW",
"reason": "Permitted by policy \"admins-read-access\"",
"matchedPolicies": [
{
"policyId": "policy-uuid-1",
"policyName": "admins-read-access",
"effect": "ALLOW",
"matched": true,
"conditionResults": [
{ "conditionType": "subject", "passed": true, "reason": "\"subject.roles\" contains \"admin\"" },
{ "conditionType": "action", "passed": true, "reason": "\"action\" is in [read, list]" }
]
}
],
"evaluatedCount": 5
}
Deny Decision Example
{
"decision": "DENY",
"reason": "Explicit DENY by policy \"deny-guests-confidential\"",
"matchedPolicies": [
{
"policyId": "policy-uuid-2",
"policyName": "deny-guests-confidential",
"effect": "DENY",
"matched": true,
"conditionResults": [
{ "conditionType": "subject", "passed": true, "reason": "\"subject.roles\" contains \"guest\"" },
{ "conditionType": "resource", "passed": true, "reason": "\"resource.attributes.classification\" equals \"confidential\"" }
]
}
],
"evaluatedCount": 5
}
Default Deny Example
{
"decision": "DENY",
"reason": "No matching policy — default deny",
"matchedPolicies": [
{ "policyName": "allow-engineering", "effect": "ALLOW", "matched": false, "...": "..." }
],
"evaluatedCount": 5
}
matchedPolicies lists every evaluated policy, with matched true or false.
Testing Policies
Test Single Policy
curl -X POST "http://localhost:3000/admin/realms/my-realm/policies/policy-uuid-123/test" \
-H "Authorization: Bearer ${ADMIN_TOKEN}" \
-H "Content-Type: application/json" \
-d '{
"subject": {
"userId": "user-uuid-123",
"roles": ["admin"],
"groups": ["engineering"]
},
"resource": {
"type": "report",
"id": "report-uuid-456"
},
"action": "read"
}'
Response:
{
"matched": true,
"effect": "ALLOW",
"detail": {
"policyId": "policy-uuid-123",
"policyName": "allow-admins-all-access",
"effect": "ALLOW",
"matched": true,
"conditionResults": [
{ "conditionType": "subject", "passed": true, "reason": "\"subject.roles\" contains \"admin\"" }
]
}
}
Client-Scoped Policies
Policies can be scoped to specific OAuth clients:
{
"name": "frontend-user-access",
"description": "User access for frontend application",
"effect": "ALLOW",
"clientId": "my-frontend-app",
"subjectConditions": [
{ "field": "subject.roles", "operator": "contains", "value": "user" }
]
}
Evaluate with Client Scope
curl -X POST "http://localhost:3000/admin/realms/my-realm/policies/evaluate" \
-H "Authorization: Bearer ${ADMIN_TOKEN}" \
-H "Content-Type: application/json" \
-d '{
"subject": { "roles": ["user"] },
"resource": { "type": "document" },
"action": "read",
"clientId": "my-frontend-app"
}'
Which policies apply to an evaluation:
| Policy | Evaluation with clientId: "my-frontend-app" | Evaluation with another clientId | Evaluation without clientId |
|---|---|---|---|
Global (clientId: null) | applies | applies | applies |
clientId: "my-frontend-app" | applies | does not apply | does not apply |
So a client-scoped policy, ALLOW or DENY, only ever applies to evaluations made for that client, and an evaluation without clientId gets the global policies only. Pass the clientId of the application the request is for whenever you use client-scoped policies; a DENY that must hold for every client belongs in a global policy.
Before 0.11.0 an evaluation without clientId got every policy of the realm, client-scoped ones included.
Policy Priority
Policies are evaluated in priority order, highest first. Priority does not change the decision: any matching DENY wins over every ALLOW, whatever their priorities. It decides the order of matchedPolicies and which ALLOW policy the reason names. Priorities are integers from 0 up.
| Priority | Use Case |
|---|---|
| 100+ | Critical policies |
| 50-99 | High-priority policies |
| 0-49 | Normal policies |
Priority Example
{
"name": "emergency-lockdown",
"description": "Block all access in emergency",
"effect": "DENY",
"priority": 1000
}
When several DENY policies match, the decision is DENY either way; the reason names the first in priority order.
Managing Policies
List All Policies
curl -X GET "http://localhost:3000/admin/realms/my-realm/policies" \
-H "Authorization: Bearer ${ADMIN_TOKEN}"
Response:
[
{
"id": "policy-uuid-1",
"name": "allow-admins-all-access",
"priority": 100,
"effect": "ALLOW",
"enabled": true
},
{
"id": "policy-uuid-2",
"name": "deny-guests-confidential",
"priority": 50,
"effect": "DENY",
"enabled": true
}
]
Get Single Policy
curl -X GET "http://localhost:3000/admin/realms/my-realm/policies/policy-uuid-123" \
-H "Authorization: Bearer ${ADMIN_TOKEN}"
Update Policy
curl -X PUT "http://localhost:3000/admin/realms/my-realm/policies/policy-uuid-123" \
-H "Authorization: Bearer ${ADMIN_TOKEN}" \
-H "Content-Type: application/json" \
-d '{
"description": "Updated description",
"priority": 75,
"subjectConditions": [
{ "field": "subject.roles", "operator": "in", "value": ["admin", "super-admin"] }
]
}'
Delete Policy
curl -X DELETE "http://localhost:3000/admin/realms/my-realm/policies/policy-uuid-123" \
-H "Authorization: Bearer ${ADMIN_TOKEN}"
Disable Policy
curl -X PUT "http://localhost:3000/admin/realms/my-realm/policies/policy-uuid-123" \
-H "Authorization: Bearer ${ADMIN_TOKEN}" \
-H "Content-Type: application/json" \
-d '{ "enabled": false }'
Evaluating from Your Application
None of the SDKs has an authorization API. Policies are evaluated by the admin API endpoint POST /admin/realms/{realm}/policies/evaluate, which needs admin credentials, so call it from a trusted backend, never from a browser or mobile app:
curl -X POST "http://localhost:3000/admin/realms/my-realm/policies/evaluate" \
-H "x-admin-api-key: $ADMIN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"subject": { "userId": "user-uuid-123", "roles": ["admin", "user"] },
"resource": { "type": "report", "id": "report-uuid-456" },
"action": "read",
"environment": { "ip": "10.1.2.3" }
}'
Best Practices
Policy Design
-
Use descriptive names: Include the purpose in the policy name
- Good:
allow-admins-manage-users - Bad:
policy-1
- Good:
-
Add descriptions: Explain the intent of each policy
{"name": "deny-guests-confidential","description": "Guests cannot access confidential resources per security policy SEC-2024-01"} -
Set priorities for readability: priority orders evaluation and the
reasontext; it never lets an ALLOW override a DENY{"name": "specific-allow","priority": 50,"description": "Listed before general allows in evaluation results"} -
Group related conditions: Use AND logic for conditions that must all match
{"logic": "AND","subjectConditions": [{ "field": "subject.roles", "operator": "contains", "value": "admin" }],"resourceConditions": [{ "field": "resource.type", "operator": "equals", "value": "admin-panel" }]}
Security Considerations
Operators are not validated when a policy is saved. A condition with a misspelled operator never passes, so a DENY policy with a typo silently never matches. Test every DENY policy with the test endpoint.
Testing Policies
- Test before deploying: Use the test endpoint to verify policy behavior
- Test edge cases: Include cases that should match and should not match
- Review condition results: Check the
reasonfield in responses
Performance
- Cache evaluations: Policy lists are cached for 60 seconds
- Optimize conditions: Avoid complex regex patterns in hot paths
- Disable unused policies: Set
enabled: falseinstead of deleting
Error Handling
Common Errors
| Error | Cause | Solution |
|---|---|---|
| 400 Bad Request | Invalid request body (for example, conditions not an array) | Check the JSON structure |
| 404 Not Found | Policy ID doesn't exist | Verify policy ID |
| 409 Conflict | Policy name already exists | Use unique names |
| 401 Unauthorized | Invalid admin API key | Check Authorization header |
Error Response Format
{
"statusCode": 400,
"message": ["subjectConditions must be an array"],
"error": "Bad Request",
"timestamp": "2026-11-16T10:00:00.000Z"
}
Next Steps
Authentication Guide Learn about OAuth 2.0 and OpenID Connect flows
MFA Setup Configure multi-factor authentication
API Reference Complete REST API documentation
React SDK Integrate Idenplane into your React application