Operations

RBAC and Access Control

Configure Keycloak roles, group membership, access policies, patient permissions, and audit controls.

Security Position

Roles define the work a user may perform. Access to a particular record also depends on the tenant, organisation, facility, patient class, protected classification, purpose of use, query type and export risk.

AMCDR checks access in layers: authenticated identity, membership scope, role keys, route authorization, executable access policies, protected-record clearances, row/query controls, and audit.

The Authentication and Access-Control Matrix explains access levels, authentication methods, patient permissions and deny precedence. It also identifies who manages each control and gives examples of access decisions.

Keycloak Roles and Assignment Groups

The Keycloak configuration defines 56 AMCDR realm roles and assignment profiles below /access-profiles. Administrators should assign the narrowest suitable group rather than attaching individual roles. Profile families cover platform administration, clinical services, MPI stewardship, privacy and release, design and integration, transfers, and Patient Portal identities.

AMCDR normalizes hyphenated Keycloak roles to internal underscore keys. For example, mpi-steward becomes mpi_steward and patient-release-manager becomes patient_release_manager. AMCDR also checks tenant context, SMART grants, patient consent, care-team privacy and protected-record policy.

KEYCLOAK_CONTAINER=terminology-keycloak-keycloak-1 \
  ./scripts/keycloak/sync-amcdr-access-model.sh

The synchronizer is additive and idempotent. It creates or updates roles, groups and group-role mappings; it does not create users, assign users, delete existing groups or alter client secrets. Export the production realm first and use a least-privilege realm-management automation identity.

Profile familyTypical assignments
/access-profiles/platformViewer, platform, system, organisation, governance and terminology administration.
/access-profiles/clinicalClinical, emergency, pharmacy, laboratory, community, maternity and neonatal users.
/access-profiles/identityMPI administrators and identity stewards.
/access-profiles/privacy-and-releaseProtected-record, break-glass, patient-release and SHR-release authorities.
/access-profiles/design-and-integrationClinical data, template, form and mapping modelers.
/access-profiles/patientsPatient Portal users; never combine with staff groups.
Access decision path
User or API keyAuthenticated caller
->
Membership scopeTenant, organisation, environment, facility
->
Role keysJob capability
->
Access policyRoute, method, path, purpose
->
Resource rulesProtected records, AQL, export
->
AuditDecision and reason

Operational Rule

Assign the smallest standard role first. Add access policies only when the standard role matrix is too broad or too narrow. Add protected-record clearances only for users who need access to VIP, sealed, national-security, witness-protected, very-high-risk, restricted-minor, or unknown protected-person records.

Do not make standard users platform_admin or super_admin to solve access problems. Those roles must remain exceptional control-plane roles.

OIDC and Local Sign-in

When Keycloak/OIDC is enabled and fully configured, AMCDR redirects unauthenticated users directly to the identity provider using authorization code with PKCE. The clinical workspace, internal API documentation, and standalone documentation use the same authentication gate and do not display the local username/password form first.

The public GET /auth/oidc/config response is authoritative. Local password sign-in is rendered only when password_enabled=true, which applies when OIDC is not configured and password authentication is enabled. If the authentication configuration cannot be checked, AMCDR shows a retry screen rather than offering a potentially disabled password workflow.

The browser client uses the exact callback https://<amcdr-public-origin>/oidc-callback. Configure that value under the Keycloak client's valid redirect URIs, configure the origin under web origins, enable Standard Flow and require PKCE S256. URL fragments such as #oidc-callback are invalid, while /oauth2/callback belongs only to a separate OAuth2 Proxy client.

Logout revokes the AMCDR bearer session and invokes Keycloak RP-initiated logout with an id_token_hint. The return page is marked explicitly signed out, so automatic SSO cannot immediately recreate the session. A new session starts only when the user selects Continue with Keycloak, which requires fresh identity-provider verification. Configure https://<amcdr-public-origin>/* as a valid post-logout redirect URI.

Interactive workspace and Patient Portal sessions terminate after 900 seconds (15 minutes) without keyboard, pointer, touch, focus, or activity in another same-origin AMCDR tab. Background refresh does not count as activity. Timeout revokes the AMCDR bearer token, clears patient and request context, invokes Keycloak logout, and returns to the explicitly signed-out page. AMCDR bearer tokens also default to 900 seconds and expired tokens cannot be refreshed.

Layers

LayerPurposeExample
AuthenticationProves the caller identity.Password login, OIDC bearer token, API key.
Membership scopePlaces the user inside a tenant, organisation, environment, and facility.Clinician at one hospital, platform admin across a tenant.
RBAC role keysGrants broad workspace or API capability.viewer, clinician, form_designer, governance_admin.
Route authorizationProtects route families before endpoint code runs./patients requires clinical roles; /admin requires admin roles.
Access policiesAllow or deny specific route areas, methods, path prefixes, roles, scopes, and purposes.Deny broad patient reads for one role; allow a role to read one analytics route.
Protected-record controlsAdds classification, clearance, break-glass, and no-existence-leak handling.VIP patient hidden from broad search unless cleared.
Resource/query controlsFilters outputs from AQL, saved queries, data browsers, reports, dashboards, and exports.Protected records excluded from AQL by default.
Clinical relationship scopeResolves service-only, care-team longitudinal, patient-self, system, administrative, or denied access.A psychiatrist sees Mental Health records; an active care-team member may see clinically necessary cross-service information.
AuditRecords the decision, actor, scope, purpose, and reason.Denied protected access, export, AQL execution, break-glass.

Production queries remain inside the caller's tenant, organisation, facility and patient-relationship scope. Every patient row must resolve to an authorized service, care-team, self/proxy or system context. Queries that omit enough patient identity for row-level enforcement are rejected for ordinary clinical users; approved aggregate reporting uses governed reporting authority and disclosure controls.

Individual User Assignment

  1. Create or confirm the user account.
  2. Create the membership in the correct tenant and organisation.
  3. Assign the user's standard operational role.
  4. Add facility or environment scope where the deployment uses those boundaries.
  5. Add extra roles only for assigned duties: template design, terminology administration, reporting, integration, or protected-record review.
  6. Add access policies when the standard route matrix needs deployment-specific restriction or exception.
  7. For protected records, assign both the workspace role and the relevant clearance.
  8. Review role assignments, access events, and policy exceptions regularly.

Platform Setup: Policy & Access

Open Super-admin -> Platform configuration -> Policy & access. Follow this order:

  1. Create the tenant, organisation, and environment first.
  2. Create users and memberships inside that scope.
  3. Assign standard role keys before creating policy exceptions.
  4. Use access policies for executable route restrictions or narrow route exceptions.
  5. Use sharing policies for cross-organisation, cross-facility, partner, national-service, or reporting data movement.
  6. Use professional duty policies for purpose-of-use, care-team, practitioner-duty, service-line, or programme controls.
  7. Use jurisdiction policy packs for country, regional, cross-border, humanitarian, or national-program rules.
  8. Use protected-record clearances separately for VIP, sealed, witness-protected, national-security, restricted-minor, or unknown protected-person records.

Use Policy & Access to narrow permissions for specific duties. If many users need exceptions, review the role families or membership scopes first.

Platform setup itemWhat it controlsExample
Access policyRoute family, HTTP method, path prefix, role, scope, purpose, and allow/deny decision.Deny broad patient browsing for temporary users.
Sharing policyData allowed to leave a scope or be consumed by a partner/reporting destination.Allow aggregate HMIS output but block identifiable export.
Professional duty policyWhether the user's duty, service line, care-team relation, or purpose supports access.Maternity clinician access to birth workflows is limited to assigned patients.
Jurisdiction packLegal, regional, or programme rules applied as a bundle.National birth/death reporting or refugee programme rules.
Protected clearanceClassification-specific access on top of RBAC.VIP_ACCESS, SEALED_RECORD_ACCESS, BREAK_GLASS_ACCESS.

Recommended Role Families

Role familyTypical role keysUse
Basic readviewerRead allowed clinical and operational surfaces.
Clinical operationsclinician, nurse, doctor, clinical_adminPatient workspace, encounters, forms, clinical capture, care workflows.
Registration and MPIregistration_clerk, mpi_admin, org_adminClient registry, patient registration, identity review, merge and reconciliation tasks.
Modelling and formsform_designer, template_admin, mapping_author, terminology_adminTemplates, forms, terminology bindings, FHIR/openEHR mappings.
Reporting and AQLreporting_analyst, governance_admin, clinical_adminAQL workbench, saved queries, HMIS, indicators, data browsers, exports.
Integrationintegration_modeler, integration_admin, scoped API keysExternal MPI, FHIR, terminology, subscriptions, outbound integration.
Protected recordsprotected_record_access plus clearancesVIP/protected record access, audit review, break-glass review, reclassification.
Platform operationsplatform_admin, system_admin, super_adminTenants, organisations, users, modules, runtime configuration, high-risk administration.

AQL, Saved Queries, And Data Browsers

AQL queries and data browsers can return more data than a patient screen. They must enforce RBAC, access policies, scope filters, protected-record filtering, export policy and audit.

SurfaceMinimum controls
AQL WorkbenchAuthenticated user, reporting/query role, tenant or organisation scope, audit event, query size and timeout limits.
Saved query executionQuery-specific permission, approved parameters, protected-record filtering, cache key includes role and scope.
Data BrowserRead role for the data domain, row-level scope filter, protected-record exclusion by default, export restrictions.
HMIS and reporting dashboardsReporting role, aggregate-safe outputs, no protected identity leakage, saved-query governance.
CSV/XML/JSON exportExport permission, purpose of use, audit event, protected-record masking or exclusion, rate limits.
AQL over protected recordsprotected_record_access plus auditor/admin clearance, purpose of use, post-review where protected rows are permitted to appear.

Access Policy Pattern

Access policies complement RBAC. They support deployment-specific restrictions and exceptions, for example blocking broad patient browsing for a temporary group or allowing a reporting role to use one approved analytics endpoint.

{
  "enabled": true,
  "effect": "deny",
  "priority": 10,
  "reason": "Temporary restriction during rollout",
  "match": {
    "route_policies": ["clinical-operations"],
    "methods": ["GET"],
    "paths": ["/patients"]
  },
  "conditions": {
    "any_role_keys": ["viewer"]
  }
}

Allow policies override standard route RBAC only when allow_route_override is explicitly true. High-risk route families such as API docs, authentication administration, metrics, platform administration, and protected-record administration remain non-overridable.

Policy Examples

NeedRecommended implementation
Block broad patient browsing for a temporary groupDeny policy on clinical-operations, GET, /patients, matched to a temporary role.
Give analysts access to saved reports but not patient editingReporting role plus allow policy for saved-query routes; no clinical write roles.
Allow a clinician to run approved AQL onlyReporting/AQL role plus saved-query permission; no broad admin role.
Let a protected-record auditor review VIP accessprotected_record_access role plus PROTECTED_RECORD_AUDITOR clearance.
Let emergency clinicians use break-glassClinical role plus BREAK_GLASS_ACCESS clearance, time limit, and mandatory review.
Restrict an integration partnerAPI key with explicit scopes and route policy; never reuse a human admin account.

Audit Requirements

AMCDR must audit role assignment changes, policy changes, protected-record access decisions, AQL execution, saved-query execution, data-browser exports, protected-record AQL access, break-glass sessions, and administrative control-plane access.

For AQL and data browsers, the event must include query or saved-query key, parameters, actor, scope, role keys, row count where available, export format, cache hit or miss where relevant, and whether protected rows were filtered, masked, or included.

Implemented clinical relationship boundary

AMCDR applies one server-derived relationship decision across patient search, Patient Workspace, openEHR composition reads, governed FHIR patient-compartment operations, SHR/IPS, documents, medication and diagnostic operations, AQL, saved queries and patient-level operational modules. Patient references in paths, query parameters, EHR identifiers, persisted FHIR resource identifiers and JSON bodies resolve back to the authoritative MPI patient before access is granted.

The Patient Workspace displays Service scope or Care team ยท cross-service. Service scope loads service-attributed compositions and medication/allergy safety data without pre-loading the longitudinal overview. Care-team scope enables clinically necessary cross-service information. Protected-template policy, patient opt-out and governed break-glass remain additive controls.