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.
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.
Allowed context shapes
Each permission uses exactly one of the following context shapes:
- Unscoped — no entity and no entity group (
contextomitted, 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.
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_permissionsclaims - 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
Requirements:
- Keys in
rolesmust match the module’s role type names (types.typeName) - Values are arrays of role IDs that must exist in the module’s role catalog
contextis 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"]
}
}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
rolesobject must exist in the module’sgetRolesresponse. Role type names (the dictionary keys) are not validated. - Entity validation — If the
contextobject includes entities, each entity ID must exist in the platform’s global entities (retrieved from thegetEntitiesendpoint). - Entity group validation — If the
contextobject includes entity groups, each entity group ID must exist in the platform’s global entity groups (retrieved from thegetEntityGroupsendpoint). - MDM scope dependencies — Dependency rules that involve
mdm::entityIdsormdm::entityGroupsare 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
rolesdictionary) - Role-combination semantics that do not involve MDM scope axes — modules define those in
dependenciesfor 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.
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 resourcesmanage: Full create, read, update, delete access to resourcessuper_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 systemgroups: User groups for organizing permissionspermissions: Permission assignments to users/groupsmodulecontexts: Module registrations and configurationsclients: OAuth2 clients for authenticationroles: 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_adminstands alone and does not requireresource,module, orgroup- For
viewandmanage, aresourceis required moduleis only applicable whenresourceispermissionsormodulecontextsgroupis only applicable whenresourceisgroups- Multiple
moduleorgroupIDs can be selected in a single permission - If no
moduleorgroupis 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:
- Control access to module-specific resources
- Managed by individual modules
- Returned via module’s
getRolesendpoint
Example: A user might have:
- IAM role:
{"action": ["manage"], "resource": ["permissions"], "module": ["data-collection"]}- Can manage permissions for the data-collection module, on users, groups, or clients the holder can also manage (Manage Users, Manage Groups, or Manage Clients) - 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
- IAM: Permission Mirroring - Cross-module permission propagation via configuration
- IAM Overview - Managing users and assigning permissions