Skip to content

IAM Roles and Permissions Model

This document explains the generic role/permission model used by IAM for permission assignment, including the structure of roles, types, dependencies, and how they apply to both module-specific roles and IAM's internal roles.

Overview

IAM delivers a generic permission-assignment system that enables flexible role-based access control across all modules. Each module configures its own role dialog via its getRoles endpoint response, defining:

  • Roles: The specific permissions users can be granted.
  • Types: Categories that organize roles into groups. They are used in the IAM UI as well as the permissions response to group roles by type.
  • Dependencies: Conditional rules that control which roles can be selected together.

This system separates the generic model/semantics (applies to all modules) from module-specific configuration.

Important: Throughout the entire IAM system, permissions use a consistent structured format with roles and context as separate keys (detailed in Permissions Object). This format is universal across storage, tokens, APIs, and all communication.

Generic Role Model

Each module provides a getRoles endpoint that returns a role catalog plus (UI) metadata. IAM uses this information to render permission assignment dialogs for that module.

getRoles Response Contract

getRoles returns the generic model as:

{
  "roles": [/* role items */],
  "types": [/* role type metadata */],
  "dependencies": [/* conditional rules */]
}
Field Type Required Description
roles array Yes List of role items defining the permissions users can be granted. Each role must reference a typeName defined in types.
types array Yes Role type metadata defining categories for organizing roles and specifying UI display behavior (selector type, visibility, grouping).
dependencies array No Conditional rules controlling which roles can be selected together, including constraints on minimum/maximum selections.

Endpoint requirements and examples are documented in Module Integration with IAM.

Role Shape

Each role has these properties:

Property Type Required Description
id string Yes Stable role identifier used in permissions
label string Yes Display name shown in UI
typeName string Yes Role type identifier (must match an entry in types)
parentId string No ID of parent role for hierarchical relationships

Example:

{
  "id": "reportViewer",
  "label": "Report Viewer",
  "typeName": "access",
  "parentId": null
}

Role Types (UI Metadata)

Role types define categories for organizing roles and specify how they should be displayed in the UI.

Property Type Required Description
typeName string Yes Unique identifier used in roles and dependencies
label string Yes Display name shown in UI
selector string Yes UI control: "checkbox", "dropdown", or "recordset"
showInitially boolean Yes Whether visible when no roles selected
group string No Optional grouping label for UI organization

Example:

{
  "typeName": "access",
  "label": "Access Level",
  "selector": "checkbox",
  "showInitially": true
}

MDM context types (entities and entity groups)

Permission context (entities and entity groups) is bound to the platform’s Master Data Management (MDM). The permission model exposes this through reserved type names with the mdm:: prefix. These types are not roles from the module role catalog. Selected values are stored on the permission as context.entities and context.entityGroups, not under roles.

Reserved Type Names

typeName Maps to Permission Field Required Description
mdm::entityIds context.entities No Entity axis. Selected IDs are written to context.entities. Declare in types to enable entity scope in the assignment UI and to reference the axis in dependencies.
mdm::entityGroups context.entityGroups No Entity group axis. Selected IDs are written to context.entityGroups. Declare in types to enable entity group scope in the assignment UI and to reference the axis in dependencies.

Important: Only these two MDM type names are supported for context selection. Other mdm::... names are not supported.

Even for MDM reserved types, all required type fields (typeName, label, selector, showInitially) must be present when the type is declared. Omitting label or selector causes a JSON parsing error.

Allowed context shapes

Each permission uses exactly one of the following context shapes:

  • Unscoped — no entity and no entity group (context omitted, or both arrays empty)
  • Entity-scoped — exactly one entity ID and no entity group
  • Entity-group-scoped — exactly one entity group ID and no entity

Other combinations are rejected (both axes filled, or more than one ID on either axis). The same rule is enforced in Permission Validation.

Assignment UI

When the module’s getRoles response declares one or both MDM types, the permission assignment dialog presents a scope step before roles: Unscoped, Entity, or Entity group. Roles are shown after the scope choice, already prefiltered to those that dependencies mark as selectable for the chosen scope. Declaring MDM types enables that scope step; it does not require selecting an entity or entity group — Unscoped remains a valid assignment.

If the module does not declare mdm::entityIds / mdm::entityGroups in types, the scope step is not offered for that module.

Minimal types declaration (enables the scope step; use showInitially: true for module role types and for MDM types):

{
  "types": [
    { "typeName": "access", "label": "Access", "selector": "checkbox", "showInitially": true },
    { "typeName": "mdm::entityIds", "label": "Entities", "selector": "dropdown", "showInitially": true },
    { "typeName": "mdm::entityGroups", "label": "Entity Groups", "selector": "dropdown", "showInitially": true }
  ]
}

Role availability per scope mode is configured with How to restrict scoped and unscoped roles in the same module under Dependencies.

Dependencies (Conditional Rules)

Dependencies define conditional logic that controls which roles can be selected together. They enable complex permission models while maintaining UI clarity.

Dependency Structure

{
  "when": {
    "item": {
      "typeName": ["roleId1", "roleId2"]
    }
  },
  "then": {
    "item": {
      "typeName": ["allowedRoleId1", "allowedRoleId2"]
    },
    "constrain": {
      "min": 0,
      "max": 5,
      "scope": "each"
    }
  }
}

Components:

  • when.item: Dictionary of typeName -> string arrays; see when.item matching below.
  • then.item: Dictionary of typeName -> allowed/required role IDs when the condition is met
  • then.constrain (optional): Limits on selections
  • min and max constrain how many selections are required or allowed from the role IDs listed under then.item. When then.item includes multiple types, scope controls whether those limits apply per type or in aggregate across those types.
  • min: Minimum number of selections required
  • max: Maximum number of selections allowed
  • scope (optional string): When then.item contains more than one type, specifies whether min and max apply to each type separately or to the combined selection across those types.
    • "any": min / max apply to the combined selection across those types (aggregate requirement - for example, at least one selection somewhere across types). Use this for intra-rule OR-style requirements.
    • "each": min / max apply separately to each type in then.item (per-type requirements). May be set explicitly for clarity.
    • Omitted or null: Treated as each (per-type). Any value other than any is evaluated as each in the permission assignment UI.
  • Special markers in then.item only (not when.item — see when.item matching):
  • "*": Represents "all items of this type"
  • []: Explicitly disables all options for that type

when.item matching

Multiple entries per type combine with AND. Negation applies only to when, not then.item.

Value Meaning
[] for a type Always matches (legacy).
"*" At least one selected (not !*).
"!*" None selected.
"!{roleId}" Role id not selected (empty selection ok).
Any other value Role id must be selected.

Example: Applies the then clause while no access role is selected.

{
  "dependencies": [
    {
      "when": { "item": { "access": ["!*"] } },
      "then": { "item": { "reportingModule": ["rm1"] } }
    }
  ]
}

Dependency Semantics

Multiple IDs in when (AND logic):

Multiple entries in a single when.item array for one type are interpreted as INTERSECTION (AND).

{
  "when": {
    "item": {
      "access": ["reportViewer", "remittanceViewer"]
    }
  },
  "then": {
    "item": {
      "dataCollection": ["*"]
    },
    "constrain": {
      "min": 1
    }
  }
}

This rule applies only if both reportViewer AND remittanceViewer are selected.

For OR semantics between different when conditions, use separate dependency rules (one rule per branch):

[
  {
    "when": { "item": { "access": ["reportViewer"] } },
    "then": { "item": { "reportingModule": ["rm1", "rm2"] } }
  },
  {
    "when": { "item": { "access": ["remittanceViewer"] } },
    "then": { "item": { "reportingModule": ["rm1", "rm2"] } }
  }
]

OR within a single dependency (multiple types in one then.item): use constrain.scope: "any" together with min / max so the limit applies in aggregate across those types — see scope under then.constrain. Example:

{
  "dependencies": [
    {
      "when": { "item": { "access": ["reportViewer"] } },
      "then": {
        "item": {
          "entityAttributeRole": ["*"],
          "mdm::entityIds": ["*"]
        },
        "constrain": { "min": 1, "scope": "any" }
      }
    }
  ]
}

Multiple dependency rules (AND logic):

When multiple rules have true when conditions, their then clauses are intersected.

[
  {
    "when": { "item": { "access": ["reportViewer"] } },
    "then": { "item": { "reportingModule": ["rm1", "rm2"] } }
  },
  {
    "when": { "item": { "dataCollection": ["dc1"] } },
    "then": { "item": { "reportingModule": ["rm2", "rm3"] } }
  }
]

If both conditions are true, available reporting modules are: ["rm2"] (the intersection).

How to restrict scoped and unscoped roles in the same module

Modules that declare MDM types can use dependencies on mdm::entityIds and mdm::entityGroups to offer different role sets for unscoped, entity-scoped, and entity-group-scoped assignment. After the user picks a scope mode, the UI shows only the role IDs listed under matching then.item entries. The same rules are enforced when the permission is saved.

If dependencies omit MDM axes entirely, or omit them for some roles, those roles stay available in every scope mode (Unscoped, Entity, and Entity group). The chosen scope alone does not narrow the catalog; only MDM-based rules do (the caller’s assignable-role filter still applies).

In then.item, each typeName maps to the allowed set of role IDs for that type when the when clause matches. For MDM axes in when.item, use "!*" (none selected) and "*" (at least one selected) as in when.item matching.

Entity and entity group modes need separate rules. Entries in one when.item combine with AND, so putting both mdm::entityIds and mdm::entityGroups in the same when requires both axes to match at once.

Example — different role sets for unscoped, entity, and entity group (typical when both entity axes are enabled):

{
  "dependencies": [
    // Roles available when unscoped (no entity and no entity group)
    {
      "when": {
        "item": {
          "mdm::entityIds": ["!*"],
          "mdm::entityGroups": ["!*"]
        }
      },
      "then": {
        "item": {
          "access": ["roleId1", "roleId2"]
        }
      }
    },
    // Roles available when scoped to an entity
    {
      "when": {
        "item": {
          "mdm::entityIds": ["*"]
        }
      },
      "then": {
        "item": {
          "access": ["roleId2", "roleId3", "roleId4"]
        }
      }
    },
    // Roles available when scoped to an entity group
    {
      "when": {
        "item": {
          "mdm::entityGroups": ["*"]
        }
      },
      "then": {
        "item": {
          "access": ["roleId2", "roleId3", "roleId4"]
        }
      }
    }
  ]
}

In this pattern, roleId1 is available only when both MDM axes are empty (unscoped). roleId3 and roleId4 are available when an entity or an entity group is selected. roleId2 appears in all three modes.

The same shape works for other role types (for example IAM-style action / resource): then.item still lists the allowed IDs for each type under that scope mode. Not every type needs an entry in every rule.

Additional dependency patterns

Dependencies can also require a scope axis when a given role is selected (quantity constraints). Example:

{
  "dependencies": [
    {
      "when": { "item": { "access": ["roleId3"] } },
      "then": { "item": { "mdm::entityGroups": ["*"] }, "constrain": { "min": 1 } }
    }
  ]
}

This requires at least one entity group when roleId3 is selected. Matching and constrain behaviour follow the rules in Dependency Structure and when.item matching.

Constraints and Policies

Policy A: No Cross-Type Parent References

A role's parentId cannot reference a role with a different typeName. Parent-child relationships must stay within the same role type.

Invalid Example:

{
  "roles": [
    {
      "id": "dc1",
      "label": "Data Collection Module",
      "typeName": "dataCollection"
    },
    {
      "id": "rm1",
      "label": "Reporting Module 1",
      "typeName": "reportingModule",
      "parentId": "dc1"  // ❌ Invalid: parent has different typeName
    }
  ]
}

This is invalid because rm1 (typeName: reportingModule) tries to reference dc1 (typeName: dataCollection) as its parent.

Valid Example:

{
  "roles": [
    {
      "id": "banking_supervisor",
      "label": "Banking Supervisor",
      "typeName": "Supervision Centre"
    },
    {
      "id": "banking_supervisor_view",
      "label": "Banking Supervisor (View Only)",
      "typeName": "Supervision Centre",
      "parentId": "banking_supervisor"  // ✅ Valid: same typeName
    }
  ]
}

This is valid because both roles share the same typeName: "Supervision Centre".

Why this matters: Hierarchical relationships (parent-child) are used for UI organization and possibly inheritance logic within a single role category. Cross-type references would create ambiguous relationships that don't fit the permission model.

Policy B: Dependency Consistency

  • All typeName values in dependencies must match entries in the types array
  • Role IDs referenced in dependencies must exist in the roles array
  • Circular dependencies should be avoided

Permissions Object

IAM uses a consistent structured format for all permissions throughout the system. This format is used universally - in storage, tokens, API requests/responses, and integration messages.

The permission structure consists of two top-level keys:

{
  "roles": {
    "access": ["roleId1", "roleId2"],
    "scope": ["roleIdA", "roleIdB"]
  },
  "context": {
    "entities": ["E1"],
    "entityGroups": []
  }
}

Required Format: The roles object is a dictionary where each key is a typeName from the module's role types (defined in the getRoles response), and each value is an array of role IDs belonging to that type. For example, if your module defines a type called "access", then roles of that type appear under the "access" key.

This exact structure is used everywhere:

  • IAM database storage of permission records
  • Token custom_permissions claims
  • Integration messages (endpoint and client permissions) - as items in a permissions array
  • IAM APIs that create, update, or retrieve permissions
  • User permissions sent in request bodies to module endpoints
  • All permission-related communication between IAM and modules

Note

In the integration messages, the permissions field is an array of permission objects, where each object follows the structure shown above. This allows modules to specify multiple sets of permissions for endpoints and clients.

Requirements:

  • Keys in roles must match the module's role type names (types.typeName)
  • Values are arrays of role IDs that must exist in the module's role catalog
  • context is optional and scopes permissions to specific entities/entity groups

Context Scoping

The optional context object limits where permissions apply. Each permission uses at most one entity or one entity group — see Allowed context shapes.

Entity-scoped example:

{
  "roles": {
    "access": ["roleId1"]
  },
  "context": {
    "entities": ["E1"],
    "entityGroups": []
  }
}

Entity-group-scoped example:

{
  "roles": {
    "access": ["roleId1"]
  },
  "context": {
    "entities": [],
    "entityGroups": ["G1"]
  }
}
  • entities: Entity IDs (at most one ID when present)
  • entityGroups: Entity group IDs (at most one ID when present)
  • If omitted or both arrays are empty, the permission is unscoped within the module

Organisation-wide entity group

When context.entityGroups contains the organisation-wide group id (default all, configurable via backend.allEntityGroupId), the permission applies to every entity, every entity group, and unscoped data on the entity axis for the roles in that permission. Module and resource constraints still apply.

{
  "roles": {
    "access": ["roleId1"]
  },
  "context": {
    "entityGroups": ["all"]
  }
}

In the permission assignment UI, context.entities and context.entityGroups are filled via the reserved MDM context types (mdm::entityIds, mdm::entityGroups) when the module declares them in getRoles. Optional dependencies can limit which roles are available for each scope mode.

Permission Validation

Every permission create or update request passes through a validation pipeline before it is persisted. The pipeline runs the following checks in order and rejects the request on the first failure.

Structure checks

  • Content required — A permission must include at least one role, entity, or entity group. A bare module reference with no content is rejected.
  • Single context item — Context must follow Allowed context shapes (at most one entity or one entity group, or unscoped with roles only).

Catalog checks

  • Role ID validation — All role IDs in the roles object must exist in the module's getRoles response. Role type names (the dictionary keys) are not validated.
  • Entity validation — If the context object includes entities, each entity ID must exist in the platform's global entities (retrieved from the getEntities endpoint).
  • Entity group validation — If the context object includes entity groups, each entity group ID must exist in the platform's global entity groups (retrieved from the getEntityGroups endpoint).
  • MDM scope dependencies — Dependency rules that involve mdm::entityIds or mdm::entityGroups are evaluated against the selected roles and context. Incompatible combinations (for example a role that the catalog only allows when unscoped, assigned with an entity) are rejected.

Principal user scope checks

For non-super-admin users, IAM additionally verifies that the requesting user's own effective permissions cover the values being assigned:

  • Role scope — The requesting user must hold every role being assigned, for the specified entity or entity group, within the target module.
  • Entity / entity group scope — Every entity or entity group in the permission must be covered by the requesting user's effective permissions for that module (including when the caller is scoped to the organisation-wide entity group).

These scope checks ensure that a user cannot grant access beyond what they themselves possess. Users with the super_admin role bypass the scope checks but still go through the structure and catalog checks described above.

What IAM does not validate

  • Role type names (keys in the roles dictionary)
  • Role-combination semantics that do not involve MDM scope axes — modules define those in dependencies for the assignment UI; only MDM-related dependency rules are enforced on save as described above

AllowAllPermissions bypass

A deployment-level configuration flag AllowAllPermissions can be enabled to skip all permission validation entirely. When this flag is active, no structure, catalog, or scope checks are performed. This option is intended for development and testing environments and should not be enabled in production.

Universal Permission Format

The structured format described above is used consistently across the entire IAM system - there are no exceptions. Whether permissions are stored in the database, transmitted in tokens, sent via API calls, or included in integration messages, they always follow the same structure with roles and context as separate top-level keys.

Token Example

Tokens contain this structured format in their custom_permissions claim:

{
  "custom_permissions": [
    {
      "module": "example-module",
      "permissions": [
        {
          "roles": {
            "action": ["view"],
            "resource": ["users", "groups"],
            "module": ["iam"]
          },
          "context": {
            "entities": ["E1"],
            "entityGroups": []
          }
        }
      ]
    }
  ]
}

IAM Module Roles

The IAM module also uses the generic model as described above, but defines a fixed set of role types and values for managing IAM resources.

IAM Role Types

The IAM module defines four role types that work together to define permissions:

Action

Defines what operations a user can perform:

  • view: Read-only access to resources
  • manage: Full create, read, update, delete access to resources
  • super_admin: Unrestricted access to all IAM functionality (bypasses other constraints)

Resource

Defines which IAM resources the action applies to:

  • users: User accounts in the IAM system
  • groups: User groups for organizing permissions
  • permissions: Permission assignments to users/groups
  • modulecontexts: Module registrations and configurations
  • clients: OAuth2 clients for authentication
  • roles: Keycloak roles management

Module

Scopes permissions and module contexts to specific registered modules. Dynamically populated based on which modules are registered in the system. Used when the resource is permissions or modulecontexts.

Group

Scopes group-related permissions to specific user groups. Dynamically populated based on which groups exist in the system. Used when the resource is groups.

How IAM Roles Work Together

Basic Rules:

  • super_admin stands alone and does not require resource, module, or group
  • For view and manage, a resource is required
  • module is only applicable when resource is permissions or modulecontexts
  • group is only applicable when resource is groups
  • Multiple module or group IDs can be selected in a single permission
  • If no module or group is selected, the permission applies to all modules/groups

IAM Permission Examples

Super Admin (Full Access):

{
  "roles": {
    "action": ["super_admin"]
  }
}

View All Users:

{
  "roles": {
    "action": ["view"],
    "resource": ["users"]
  }
}

Manage Users and Clients:

{
  "roles": {
    "action": ["manage"],
    "resource": ["users", "clients"]
  }
}

View Permissions for Specific Module:

{
  "roles": {
    "action": ["view"],
    "resource": ["permissions"],
    "module": ["data-collection"]
  }
}

Manage Specific Group:

{
  "roles": {
    "action": ["manage"],
    "resource": ["groups"],
    "group": ["administrators"]
  }
}

View Permissions with Entity Context:

{
  "roles": {
    "action": ["view"],
    "resource": ["permissions"],
    "module": ["data-collection"]
  },
  "context": {
    "entities": ["E1"],
    "entityGroups": []
  }
}

Integration with Module Roles

The IAM role system is independent from module-specific roles:

IAM Roles:

  • Control access to IAM resources (users, groups, permissions)
  • Managed by the IAM Module
  • Used in IAM UI and APIs

Module Roles (see Module Integration with IAM):

  • Control access to module-specific resources
  • Managed by individual modules
  • Returned via module's getRoles endpoint

Example: A user might have:

  • IAM role: {"action": ["manage"], "resource": ["permissions"], "module": ["data-collection"]} - Can manage permissions for data-collection module
  • Data Collection role: {"access": ["report_editor"]} - Can edit reports in data-collection module

The permissions from IAM and another module are maintained separately, but play together: IAM roles control access to IAM administrative functions (managing users, assigning permissions), while module roles control access to module-specific features. In order to be able to properly carry out actions within IAM, a user needs appropriate IAM roles (e.g. to administer permissions or users) but needs module roles to actually use module functionality in these actions.

See Also