---
title: "Understanding Claim Logic in Policies: AND, OR and Conflicting Claims"
description: "How Nodinite evaluates Claims in Policies: AND logic within a Policy, OR logic between the Policies of a Role, the conflicting Claims problem with one Key and two values, separate Policies for OR logic, and the validation rules that stop an empty Policy."
---

# :fa-scale-balanced: Understanding Claim Logic in Policies

A [Policy][What is a Policy] grants access only when the user's access token holds its [Claims][]. How several Claims, and several Policies on one [Role][Roles], combine decides who gets in, and a wrong change can lock everyone out.

* ✅ **AND** within a Policy: every Claim must match  
* ✅ **OR** between the Policies of a Role: one matching Policy is enough  
* ✅ **Conflicting Claims**: one Key with two values in one Policy, and the fix  
* ✅ **Validation rules** that stop an empty Policy  

>[!IMPORTANT]
>**CRITICAL: Modifying Policies Can Lock Out All Users (Including Admins)**
>
>1. **AND Logic:** ALL Claims in a Policy must match. Adding one Claim makes access MORE restrictive
>2. **IDP Dependency:** Claims must exist in your Identity Provider (Microsoft Entra ID, Okta, etc.) with exact key/value match ([Entra ID Token Claims Validation][])
>3. **Fast Effect:** A Policy, Claim, or Role change in :Nodinite: reaches signed-in users within about 15 seconds, without signing in again
>4. **Lockout Risk:** The [Web API][] refuses an edit or delete that would take the Administrators Role from the administrator making it (HTTP 409), but other administrators and users can still be locked out
>
>**Real-world disaster scenario:**
>
>```text
>You have Policy "Administrators" with:
>  - Group=Admin
>
>You add "MFAVerified=true" thinking it adds security:
>  - Group=Admin (AND)
>  - MFAVerified=true (AND)
>
>Problem: Your IDP doesn't send "MFAVerified" claim
>Result: NO other user matches (Group=Admin AND MFAVerified=true)
>Impact: every other administrator loses the Role within 15 seconds ❌
>```
>
>**:fa-clock: When changes arrive:** :Nodinite: reads the Claims from each request's token and caches only the Roles, Policies, and Claims structure, for 15 seconds per user. A change in the identity provider (for example a user's group) arrives with the user's next token: at sign-in, or at the next refresh (the [Web Client][] refreshes the access token 2 minutes before it expires; Microsoft Entra ID tokens typically live 60–90 minutes). Signing out and in again fetches a new token at once. See [Install Nodinite v7 - OpenID][] for the token settings.
>
>**Safe practices:**
>
>* ✅ Create NEW Policies instead of modifying existing ones
>* ✅ Document all Claims your IDP provides before creating Policies
>* ✅ Test with non-admin test accounts first
>* ✅ Sign out and in again after an identity provider change, instead of waiting for the token to expire
>* ✅ Never modify the built-in "Administrators" Policy without a tested backup plan
>* ❌ Never add Claims "just to see what happens"
>* ❌ Never test Policy changes using your only admin account

## AND Logic Within a Policy

**Critical Rule:** All Claims within a single Policy use **AND** logic. Users must match **ALL** Claims in the Policy to satisfy it. Key and Value are trimmed and compared without regard to case (`Group = contoso-finance` matches `Contoso-Finance`).

![Animation: the Policy Contoso: Finance Users gets a second Claim, Group = Contoso-Managers; the user contoso.finance, whose token lacks it, signs in and gets the Forbidden page][1]  
*One extra Claim is enough: `contoso.finance` has no Contoso-Managers group, so the Policy no longer matches and the user gets the **Forbidden** page.*  

<div class="mermaid">
graph TB
    subgraph Role["Nodinite Role: Admin"]
        direction LR
        R["Role receives access if user matches ANY Policy"]
    end
    subgraph OR_Logic[" "]
        direction TB
        P1["Policy: AdminInDenmark"]
        P2["Policy: AdminInSweden"]
        P3["Policy: AdminInNorway"]
    end
    subgraph P1_Claims["Policy: AdminInDenmark"]
        direction TB
        C1["Group: AdminInDenmark"]
    end
    subgraph P2_Claims["Policy: AdminInSweden"]
        direction TB
        C2A["Country: Sweden"]
        C2B["Group: Admin"]
        C2A -.->|"AND"| C2B
    end
    subgraph P3_Claims["Policy: AdminInNorway"]
        direction TB
        C3A["Country: Norway"]
        C3B["Group: Admin"]
        C3A -.->|"AND"| C3B
    end
    Role -->|"OR"| P1
    Role -->|"OR"| P2
    Role -->|"OR"| P3
    P1 --> P1_Claims
    P2 --> P2_Claims
    P3 --> P3_Claims
    style Role fill:#FFD525,color:#000
    style P1 fill:#2678BD,color:#fff
    style P2 fill:#2678BD,color:#fff
    style P3 fill:#2678BD,color:#fff
    style P1_Claims fill:#3F827B,color:#fff
    style P2_Claims fill:#3F827B,color:#fff
    style P3_Claims fill:#3F827B,color:#fff
    style C1 fill:#93d16d,color:#000
    style C2A fill:#93d16d,color:#000
    style C2B fill:#93d16d,color:#000
    style C3A fill:#93d16d,color:#000
    style C3B fill:#93d16d,color:#000
</div>

*Yellow: the Role (OR between its Policies); blue: the Policies; teal boxes: the Claims of each Policy, in green, joined by AND.*

### Key Insights

* **OR between Policies** - User needs to match ANY ONE of the Policies assigned to the Role
* **AND within Policies** - User must match ALL Claims within a single Policy
* If user satisfies AdminInSweden Policy (has Country=Sweden AND Group=Admin), they get Admin role ✅
* If user satisfies AdminInNorway Policy (has Country=Norway AND Group=Admin), they get Admin role ✅
* If user satisfies AdminInDenmark Policy (has Group=AdminInDenmark), they get Admin role ✅

### Example: AdminInSweden

```text
Policy: "AdminInSweden"
Claims:
  * Country=Sweden (AND)
  * Group=Admin   (AND)
```

**Result:** Users must have **BOTH** Claims to match this Policy:

* ✅ [User][Users] has `Country=Sweden` AND `Group=Admin` → **Access granted**
* ❌ User has only `Country=Sweden` → **Access denied**
* ❌ User has only `Group=Admin` → **Access denied**

## OR Logic Between Policies

To achieve **OR** logic, create **separate Policies** and assign both to the same [Role][Roles]. You assign a Policy to a Role in the Policy's **Roles** card; the Role's **Policies** card only lists them.

![Animation: the Role Contoso: Operations has one Policy; a second Policy, Contoso: Logistics Users with Group = Contoso-Logistics, is added for the same Role, and the user contoso.logistics signs in and sees the Role's Log Views][2]  
*Two Policies on one Role: a user who matches either one, here `contoso.logistics`, gets the Role.*  

### Example: Nordic Administrator

```text
Policy: "AdminInDenmark"
Claims:
  * AdminInDenmark=true

Policy: "AdminInSweden"
Claims:
  * AdminInSweden=true

Policy: "AdminInNorway"
Claims:
  * AdminInNorway=true

Role: "Nordic Administrator"
Policies:
  * AdminInDenmark (OR)
  * AdminInSweden (OR)
  * AdminInNorway (OR)
```

**Result:** Users with **ANY** of these Claims get the "Nordic Administrator" role:

* ✅ User has `AdminInDenmark=true` → **Access granted**
* ✅ User has `AdminInSweden=true` → **Access granted**
* ✅ User has `AdminInNorway=true` → **Access granted**
* ✅ User has all three Claims → **Access granted**

## The Conflicting Claims Problem

>[!IMPORTANT]
>**Avoid several Claims with the same Key but different Values in one Policy.** :Nodinite: doesn't stop you, but the Policy then requires *both* values, which a single-valued claim can never satisfy.

### Invalid Policy Configuration

```text
Policy: "Nordic Admin" (INVALID!)
Claims:
  * Country=Denmark (AND)
  * Country=Sweden  (AND)
  * Country=Norway  (AND)
```

### Why This Fails

1. Policy requires ALL Claims (AND logic)
2. A single-valued claim such as `Country` carries **one value** in the token
3. User cannot have `Country=Denmark` AND `Country=Sweden` simultaneously
4. ❌ **No user can ever satisfy this Policy**
5. ❌ **Everyone is blocked from access**

A multi-valued claim is different: every value in the token counts, so a user in two groups satisfies `Group=Finance` AND `Group=Managers`. That is a valid way to require membership of both groups.

### Visual Representation

```text
User's Claims from IDP:
  AdminInDenmark: true
  Group: Admin

Policy "Conflicting Example" requires:
  AdminInDenmark: true  (AND)  ← User has this
  AdminInDenmark: false (AND)  ← User doesn't have this

Result: Policy NOT satisfied → Access DENIED
```

## Correct Pattern: Separate Policies for OR Logic

### Valid Configuration

```text
Policy: "DenmarkAccess"
Claims:
  * Country=Denmark

Policy: "SwedenAccess"
Claims:
  * Country=Sweden

Policy: "NorwayAccess"
Claims:
  * Country=Norway

Role: "Nordic Administrator"
Policies:
  * DenmarkAccess
  * SwedenAccess
  * NorwayAccess
```

**Result:** Users from **any** Nordic country get access:

* ✅ User with `Country=Denmark` → Matches "DenmarkAccess" Policy
* ✅ User with `Country=Sweden` → Matches "SwedenAccess" Policy
* ✅ User with `Country=Norway` → Matches "NorwayAccess" Policy

## Validation Rules

:Nodinite: enforces these validation rules when managing Policies:

### Empty Policy Detection

The Web Client keeps **Save** disabled and shows *You must select at least one Claim and at least one Role to be able to save the Policy.* until the Policy has both. :new7.12: The [Web API][] applies the same rule: it refuses a Policy without a Claim or without a Role with **HTTP 400**, also when a script or an MCP tool sends it. An empty Policy grants nothing: Policies without Claims, and deleted Policies or Claims, are skipped when :Nodinite: works out a user's Roles.

The name must be unique, compared without regard to case and including deleted Policies; otherwise the Web API answers *Policy Name '…' is already in use*. Restore the deleted Policy instead of creating a new one.

There is no check for two Claims with the same Key: see [The Conflicting Claims Problem](#the-conflicting-claims-problem) for when that works and when it locks everyone out.

### Complex Scenarios

##### Valid: Multiple Keys, Different Values

```text
Policy: "Finance Manager Sweden"
Claims:
  * Department=Finance     ← Different key
  * Country=Sweden         ← Different key
  * AccessLevel=Admin      ← Different key
  * Environment=Production ← Different key
```

All different keys → ✅ Valid

##### Invalid: Same Key, Different Values

```text
Policy: "Multi-Environment" (INVALID!)
Claims:
  * Environment=Production (AND)
  * Environment=Test       (AND)
```

Same single-valued key with different values → ❌ No user can match

##### Valid but Redundant: Same Key, Same Value

```text
Policy: "Redundant Example"
Claims:
  * Country=Sweden
  * Country=Sweden  ← Duplicate, but same value
```

Same key with same value → ✅ Valid but redundant (system may deduplicate)

## :fa-hand-point-right: Next Steps

* :fa-shield-halved: [What is a Policy?][What is a Policy]  
* :fa-pen-to-square: [Add or manage Policy][]  

## :fa-link-horizontal: Related Topics

* :fa-tag: [What is a Claim?][Claims]  
* :fa-user-shield: [What is a Role?][Roles]  

[1]:{ndm}/Documentation%20Pictures/IM/WebClient/Admin/Authorization/Policies/Policies_AndLogic.gif
[2]:{ndm}/Documentation%20Pictures/IM/WebClient/Admin/Authorization/Policies/Policies_OrLogic.gif

[Add or manage Policy]:{ndr}/Administration/3.%20Access%20Management/5.%20Policies/Features/Add%20or%20manage%20Policy.md
[Claims]:{ndr}/Administration/3.%20Access%20Management/4.%20Claims/Features/What%20is%20a%20Claim.md
[Entra ID Token Claims Validation]:{ndr}/Install%20and%20Update/Troubleshooting/Azure/Entra%20ID%20Token%20Claims%20Validation.md
[Install Nodinite v7 - OpenID]:{ndr}/Install%20and%20Update/Getting%20started/Version%207/Install%20Nodinite%20v7%20-%20OpenID.md
[Roles]:{ndr}/Administration/3.%20Access%20Management/1.%20Roles/Features/What%20is%20a%20Role.md
[Users]:{ndr}/Administration/3.%20Access%20Management/2.%20Users/Features/What%20is%20a%20User.md
[Web API]:{ndr}/Core%20Services/Web%20API/Overview.md
[Web Client]:{ndr}/Getting%20Started/Overview.md
[What is a Policy]:{ndr}/Administration/3.%20Access%20Management/5.%20Policies/Features/What%20is%20a%20Policy.md