Skip to main content

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:

ApproachDescriptionUse Case
RBACRole-based permissions assigned to usersBasic access control
ABAC PoliciesAttribute-based rules with conditionsComplex, dynamic access decisions

Authorization Flow​

DENY-Override Algorithm​

Idenplane uses a DENY-override algorithm:

  1. The enabled policies that apply to the request's client are kept (see Client-Scoped Policies)
  2. They are sorted by priority (highest first)
  3. Each policy is evaluated against the request
  4. If any DENY policy matches → final decision is DENY
  5. If at least one ALLOW policy matches → final decision is ALLOW
  6. 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).

Default Deny

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​

RolePermissions
adminFull access to all resources
moderatorManage content, view reports
userRead/write own resources
guestRead-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​

FieldTypeRequiredDescription
namestringYesUnique policy name within realm
descriptionstringNoHuman-readable description
enabledbooleanNoWhether policy is active (default: true)
effectstringNo"ALLOW" or "DENY" (default: "ALLOW")
priorityintegerNoHigher = evaluated first (default: 0)
logicstringNo"AND" or "OR" for conditions (default: "AND")
clientIdstringNoScope the policy to one client (its clientId). It then applies only to evaluations that pass the same clientId
subjectConditionsarrayNoConditions on the subject (user)
resourceConditionsarrayNoConditions on the resource
actionConditionsarrayNoConditions on the action
environmentConditionsarrayNoConditions 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​

OperatorDescriptionvalue
equalsExact matcha string, number, boolean or null
notEqualsNot equala string, number, boolean or null
containsThe string contains the value, or the array has it as an elementa string, number, boolean or null
inThe field's value is one of the array's elementsan array, e.g. ["read", "write"]
notInThe field's value is none of theman array, e.g. ["delete"]

Numeric Operators​

OperatorDescriptionvalue
greaterThanNumeric comparison, e.g. level > 5a number, or a string holding one
lessThanNumeric comparison, e.g. count < 100a number, or a string holding one

Pattern Operators​

OperatorDescriptionvalue
matchesRegex match, e.g. email matches ^[^@]+@company\.com$a JavaScript regular expression of at most 256 characters, without backreferences or nested repetition (see below)
ipInRangeThe IP address is in the rangean 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 but ALLOW and DENY) is treated as DENY, and an unknown logic makes 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

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:

PathDescriptionExample Value
subject.userIdUser ID"user-uuid-123"
subject.rolesUser roles array["admin", "user"]
subject.groupsUser groups array["engineering"]
subject.attributesCustom attributes{ "department": "eng" }
resource.typeResource type"report"
resource.idResource ID"resource-uuid"
resource.ownerIdResource owner"user-uuid-123"
resource.attributesResource attributes{ "classification": "secret" }
actionAction name"read"
environment.ipClient IP address"192.168.1.1"
environment.timeRequest 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.

Owner-only access

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:

PolicyEvaluation with clientId: "my-frontend-app"Evaluation with another clientIdEvaluation without clientId
Global (clientId: null)appliesappliesapplies
clientId: "my-frontend-app"appliesdoes not applydoes 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.

Changed in 0.11.0

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.

PriorityUse Case
100+Critical policies
50-99High-priority policies
0-49Normal policies

Priority Example​

{
"name": "emergency-lockdown",
"description": "Block all access in emergency",
"effect": "DENY",
"priority": 1000
}
note

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​

  1. Use descriptive names: Include the purpose in the policy name

    • Good: allow-admins-manage-users
    • Bad: policy-1
  2. Add descriptions: Explain the intent of each policy

    {
    "name": "deny-guests-confidential",
    "description": "Guests cannot access confidential resources per security policy SEC-2024-01"
    }
  3. Set priorities for readability: priority orders evaluation and the reason text; it never lets an ALLOW override a DENY

    {
    "name": "specific-allow",
    "priority": 50,
    "description": "Listed before general allows in evaluation results"
    }
  4. 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​

Check operator names

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​

  1. Test before deploying: Use the test endpoint to verify policy behavior
  2. Test edge cases: Include cases that should match and should not match
  3. Review condition results: Check the reason field in responses

Performance​

  1. Cache evaluations: Policy lists are cached for 60 seconds
  2. Optimize conditions: Avoid complex regex patterns in hot paths
  3. Disable unused policies: Set enabled: false instead of deleting

Error Handling​

Common Errors​

ErrorCauseSolution
400 Bad RequestInvalid request body (for example, conditions not an array)Check the JSON structure
404 Not FoundPolicy ID doesn't existVerify policy ID
409 ConflictPolicy name already existsUse unique names
401 UnauthorizedInvalid admin API keyCheck 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


idenplane.com · GitHub · Discord