Skip to main content

How access is decided

Two separate questions are answered on every request, and it helps to keep them apart when debugging:

  • Authentication: who is this caller, and which project are they acting in?
  • Authorization: may this caller perform this operation on this resource type?

A token that passes the first can still be refused by the second. A denial naming your role and a resource type is always the second.

Identity​

A bearer token is validated against the project's identity provider, and two claims are read out of it: an entity type (Patient, Practitioner, RelatedPerson, Device) and an entity id (a FHIR logical id). Together they are the caller's identity, and everything downstream operates on that pair. Confirm what your token resolved to with Me:

query {
Me {
reference
}
}

The request must also name a project, and the project named in the token must match the one in the X-Project-ID header. See the project binding.

Access is denied unless a rule grants it​

Every permission on a resource exists because someone wrote a rule for that exact client_role / entity_name / operation triple, and a triple with no rule is refused. There is no permissive fallback and no implicit grant for "obviously safe" resources.

  • A missing rule is a denial, not a gap to be discovered later. Searches come back [] and reads come back null, with no error to say why. If a screen in your application is empty, the first thing to check is whether the triple it needs has a rule.
  • Broad access is something you choose and can explain. Where a grant is deliberately wide, write it down next to the rule.

Rules​

A rule matches on three fields and names the validator that decides:

{
"client_role": "Practitioner",
"entity_name": "Observation",
"operation": "read",
"validator": "legitimate_interest"
}
FieldMeaning
client_rolethe caller's resolved entity type
entity_namethe FHIR resource type being accessed
operationcreate, read, update, delete or search
validatorwhich validator decides the request

Matching is on the exact triple. All three are compared as literal strings, and there is no wildcard. A search with no search rule falls back to that triple's read rules; that is the only fallback in the system.

Every matching rule must pass. Two rules on the same triple mean the request must satisfy both, so a second rule always narrows access and never widens it. To grant access you remove the restrictive rule; you do not add a permissive one beside it.

No matching rule means denied. A rule naming a validator that does not exist is denied rather than ignored.

Rules may additionally require the caller to hold a specific clinical role. See Requiring a practitioner role.

The order of decision​

  1. Platform checks, before any rule is read. Three of them, listed under Behaviour you cannot configure.
  2. default_access: "Allowed", if set. A read or search is granted here without reading a rule. Writes proceed to rule matching.
  3. Rule matching, on the exact triple.
  4. The search fallback. A search with no search rule is decided by the triple's read rules.
  5. default_access, when nothing matched. "Forbidden" denies. "Allowed" grants, which is why an unmatched write is permitted under it.
  6. The validator named by each matching rule.

On reads and searches the validator runs twice: once before anything is fetched, deciding on the resource type alone, and again on each row that comes back. The second pass is what makes compartment scoping real. A refused request never reaches the FHIR store at all.

Validators​

There are exactly ten. A rule naming anything else, including a differently cased spelling such as PatientCompartment, is not recognised and the request is denied.

ValidatorDecides access by
patient_compartmentthe resource being in the caller's patient compartment
practitioner_compartmentthe resource being linked to the caller as practitioner
relatedperson_compartmentthe resource being in the caller's RelatedPerson context
organization_compartmentthe caller's active organization relationships
organization_consentthe caller's active organization relationships AND an active Consent naming the caller or their organization
device_compartmentthe device's own compartment, and optionally its organization
general_practitionerthe patient's generalPractitioner references
legitimate_interestthe platform's legitimate-interest table for that resource type and role
allowednothing; it inspects no row, beyond refusing a create whose id already exists
forbiddennothing; it denies unconditionally

Each has a page under Validators.

ScenarioValidator
Patient accessing their own lab resultspatient_compartment
Practitioner updating an order they authoredpractitioner_compartment
Practitioner reaching everything in their clinicorganization_compartment
Practitioner reaching only patients who consented to them or their organizationorganization_consent
A GP reaching the records of patients who name themgeneral_practitioner
Cross-organizational access under a regulatory basislegitimate_interest
A device submitting the data it measuresdevice_compartment
A device reading organisation-level data it did not generatedevice_compartment with organisation scoping, in preference to allowed
Genuinely shared reference dataallowed, chosen deliberately and documented
allowed is a blanket grant, not a light check

It inspects nothing. Pairing allowed with read on a resource type carrying patient data grants a read of every such resource in the project. That is occasionally what you want, but it should always be a deliberate choice rather than a way to make a stubborn rule pass.

Platform rules are merged into every project​

A fixed set of platform rules is prepended to every project's own rules. They are not visible in the project's configuration and cannot be removed from it, but they can be narrowed: they merge in as ordinary rules, every rule matching a request has to pass, so a forbidden rule of your own on the same triple refuses it.

RolesResourceOperations
Patient, Practitioner, Device, RelatedPersonMeread
Patient, Practitioner, Device, RelatedPersonUploadFilecreate, read
DeviceCommunicationcreate, read, update

All of them use the allowed validator. If your project must not permit device messaging, add Device / Communication rules with the forbidden validator for all three operations; the platform's read grant applies no compartment filter, so leaving it in place returns every Communication in the project to any of that project's devices.

Behaviour you cannot configure​

Three things are decided in code and apply to every project regardless of its rules. They exist because the rule schema has no way to express them.

  • Me is always readable. It is not a FHIR resource type, so no rule can match it. It resolves from your own token and reads nothing.
  • AuditEvent is read-only. Any operation other than read or search is refused. Reads and searches of AuditEvent are decided by your rules in the normal way.
  • Communication writes are checked for thread and sender forgery, so a caller cannot attach a message to a conversation they are not part of, or send one attributed to someone else. Ordinary clinical Communication resources are left to your rules.

Configuration shape​

{
"rbac": {
"default_access": "Forbidden",
"validators": {
"legitimate_interest": {
"role_inheritance_levels": 1,
"enabled": true
}
},
"validation_rules": []
}
}

default_access recognises exactly two values, "Forbidden" and "Allowed", compared literally. "Forbidden" is the secure default and what the shipped templates use.

"Allowed" grants anything your rules do not cover

default_access is consulted only where no rule matches the role, resource and operation. Where a rule exists, that rule decides. Where none exists, "Allowed" grants reads, searches and writes that no rule covers. Do not use it in production; the publish step rejects it for new configurations. See Writing access rules for the full order.