Security
A clinical data repository holds PHI, so its access controls and audit trail are part of the product. This chapter covers the four security surfaces you configure when you deploy FerroEHR: authentication (who is calling), authorization (what they may do), the pseudonymisation boundary (which role reads which domain), and the ATNA audit trail (recording what happened). Each is independently configurable, and each is described here in terms of the environment variables you actually set.
This chapter tells you how to configure each control. Its companions tell you the rest: the Threat model states what remains true after each control has done its job: the trust boundaries, the residual risk at each, and what this software explicitly does not defend against; and Verifying releases covers the artifacts themselves: how to establish that the binary, image, or chart you downloaded came from this project’s own build. Read the threat model before you decide a control is sufficient for your deployment.
- Authentication
- Authorization
- Response security headers
- Request limits and rate limiting
- Operational surfaces: what is reachable, and by whom
- Secrets: mount files, never bake values
- Verifying what you pulled
- The pseudonymisation boundary
- One instance, one organisation
- Version signing
- ATNA audit trail
Configuration follows the same pattern throughout: the server reads defaults,
then the single ferroehr.toml file, then environment variables, with __
separating nested keys. The security configuration groups live in
distinct sections of ferroehr.toml: [auth] (authentication), [authz]
(authorization), [privacy] (the pseudonymisation boundary), and [audit]
(the ATNA audit trail). Any key can be overridden with the matching
FERROEHR_* environment variable shown below.
Authentication
Authentication is on by default (FERROEHR__AUTH__ENABLED=true). Setting
it to false lets all requests through unauthenticated, a development-only
mode.
There is no single “mode” switch. The server offers two mechanisms and enables
each by the presence of its configuration. Both are checked by
ferrohealth-smart, the resource-server crate every FerroHEALTH product
shares; FerroEHR checks tokens and never issues them.
- HTTP Basic is active when
[[auth.basic.users]]lists a user. Each user has a user-id and an Argon2id password hash (a PHC string beginning$argon2id$) or apassword_hash_filepointing at one, and nothing else: the SMART on openEHR scopes and the RBAC roles it holds are thehold_scopesandhold_rolesgrants of itsPERSONin the CDR, and[authz.rbac] first_adminnames the one Basic user that holdsadmin_roleand the product scope from the configuration. Because it is a list of users, the Basic store is normally supplied through the TOML configuration file rather than environment variables. - OAuth 2.0 bearer tokens are active when
[auth]names anissuer. The server reads the issuer’s metadata and key set at boot and validates every token’s signature (asymmetric algorithms only), issuer, audience, lifetime and type under RFC 9068.
Every person a request comes from is bound to a demographic PERSON, and the
server writes each version’s committer from that party:
Who is the committer.
Both mechanisms are validated at startup, and a configuration the server cannot honour refuses to boot rather than degrading at the first request:
| Configuration | Boot outcome |
|---|---|
auth.enabled = true with no mechanism | error: a 401 challenge must name a scheme the server implements (RFC 9110 §11.6.1) |
an issuer with no audience | error: a server with no declared audience cannot reject another server’s token (RFC 9068 §4, RFC 8725 §3.9) |
an issuer not https (plain http is accepted on a loopback host only), carrying a query or fragment, or a user name or password | error: RFC 8414 §2, §6.2; OpenID Connect Core 1.0 §1.2 |
| an issuer whose metadata or key set cannot be read | error: the start is refused rather than the first request |
clock_skew above "5min" | error: leeway may be “no more than a few minutes” (RFC 7519 §4.1.4) |
algorithms naming an HS* algorithm, or empty | error: the server accepts asymmetric algorithms only (RFC 8725 §3.1, §3.2) |
a jwks_file holding a symmetric key or a private-key member | error: a verifier holds public keys only |
a product_scope that is neither a full URI nor starts with __ | error: SMART App Launch 2.2.0, Scopes and Launch Context, §Extensibility |
a password_hash below m=19456,t=2,p=1 argon2id | error: the OWASP Argon2id floor |
[authz.assurance] minimum with an empty levels map, or with no mapped value at or above it | error: every patient-data request would be refused |
an [authz.assurance] levels value that is blank or carries whitespace, a quote or a backslash | error: the step-up challenge names the values in one quoted acr_values parameter (RFC 9470 §3) |
[authz.professional] | error: removed; the issuer’s kind and profile classify the caller |
a persons issuer with no [[auth.party]] table, two issuers sharing an audience, or no [authz.party_binding] provider | error: every person is bound to a party, under the provider the deployment acts for |
a Basic user with no [[authz.party_binding.basic_user]] mapping | error: a Basic user is a person, bound by its key |
an [authz.rbac] role_issuers entry that is not a persons issuer | error: only a person holds an administrator or emergency role |
Successfully verified Basic credentials are cached for
FERROEHR__AUTH__BASIC__CACHE_TTL (default 5min; 0s turns the cache off
and checks every request) so a busy client pays the deliberately expensive Argon2 verification
once per TTL instead of on every request. The cache names each entry by a keyed
hash of the credential, never the password, and an entry exists only after a
successful verification. The user list and its password hashes are read at
boot, so removing a user or changing a password takes effect at the restart
that loads the new list, and that restart also empties the cache: the TTL never
keeps a removed user working.
The bearer settings:
| Environment variable | Default | Meaning |
|---|---|---|
FERROEHR__AUTH__ISSUER__0__ISSUER | unset (required for bearer tokens) | the first [[auth.issuer]] table’s expected iss, and where the metadata is read: RFC 8414 §3 first, OpenID Connect Discovery 1.0 §4 after a 404; index 1 is the second table |
FERROEHR__AUTH__ISSUER__0__KIND | required | persons, patients, machines or federation: whose tokens the issuer signs |
FERROEHR__AUTH__ISSUER__0__PROFILE | rfc9068 | the preset of the issuer’s token shape: rfc9068, entra, keycloak, okta or nl |
FERROEHR__AUTH__ISSUER__0__AUDIENCE | unset (required with an issuer) | accepted aud values |
FERROEHR__AUTH__ISSUER__0__ALGORITHMS | RS256,RS384,PS256,PS384,ES256,ES384 | accepted signing algorithms, asymmetric only |
FERROEHR__AUTH__ISSUER__0__CLOCK_SKEW | 60s | leeway on exp, nbf and iat; capped at 5min |
FERROEHR__AUTH__ISSUER__0__JWKS_FILE | unset | a static JWK Set of public keys, read instead of the issuer’s metadata |
FERROEHR__AUTH__ISSUER__0__JWKS_MAX_AGE | 10min | a key set older than this is read again |
FERROEHR__AUTH__ISSUER__0__JWKS_REFRESH_INTERVAL | 1min | an unknown kid reads the key set again at most once per interval |
FERROEHR__AUTH__ISSUER__0__TIMEOUT | 10s | one call to the authorization server |
FERROEHR__AUTH__REALM | ferroehr | the realm every challenge names |
FERROEHR__AUTH__PRODUCT_SCOPE | __ferroehr.platform | the scope that admits the ADMIN and DEMOGRAPHIC APIs |
There is no separate key-set URL to set: the server reads the jwks_uri from
the issuer’s metadata unless you supply a JWKS_FILE. A rotated key is picked
up on the first token that names it, bounded by the refresh interval, and a
withdrawn key stops verifying within the max age.
Every route also enforces its SMART on openEHR requirement: a valid token or
Basic user whose scopes do not grant the operation is refused with 403. See
SMART App Launch.
Tip
Keycloak example. Point the issuer at your realm and let discovery do the rest:
export FERROEHR__AUTH__ISSUER__0__ISSUER=https://keycloak.example/realms/ferroehr export FERROEHR__AUTH__ISSUER__0__KIND=persons export FERROEHR__AUTH__ISSUER__0__PROFILE=keycloak export FERROEHR__AUTH__ISSUER__0__AUDIENCE=ferroehr-apiA person signs in through a client the CDR grants
sign_in_persons, such as the viewer, on theAGENTcarrying its client id under the realm.Keycloak’s access tokens carry
typ: JWT, outside the RFC 9068 profile the server expects by default, which thekeycloakprofile admits. The client’s default client scopes put the SMART on openEHR scopes the routes need into each token’sscopeclaim.The same pattern works for Active Directory or any standards-compliant identity provider; walkthroughs for Entra ID and AD FS (and the answer for plain-LDAP directories) are in Enterprise identity providers. User accounts, roles, and lifecycle are administered in the IdP; the CDR has no user API.
An unauthenticated request to a protected route is refused with 401; an
authenticated request that lacks the required role or scope is refused with
403. Two outcomes are neither: a malformed Authorization header, or two
of them, is a 400 (the server never read a credential), and an unreadable
key set is a 503 (no token can be validated, so the server cannot decide; it
is not a statement about the caller’s credential). The per-status table for
client authors is in Using the API.
The 401 body deliberately says nothing about why, and neither does the
challenge: every token that does not hold gets the one invalid_token answer
(RFC 9068 §4), with no error_description. Rendering the rejection would tell
an unauthenticated caller whether a token was expired or forged, which is
exactly the distinction an attacker probes for; the reason stays in the debug
log, where the operator can read it and the caller cannot. A 403 names no
scope either, in its challenge or its body. A request that carried no
credential at all, or one for a scheme the server does not admit, gets no error
code: it has not made a mistake yet (RFC 6750 §3.1).
Assurance level and the natural person on patient data
Two optional blocks under [authz] judge how a professional
authenticated and who stands behind a token. Both are off by default; with
neither configured nothing below changes the wire.
[authz.assurance] reads the authentication assurance level from a
token claim (claim, default acr) and maps each value your identity provider
emits to an eIDAS level (levels: low, substantial or high). With
minimum set, a patient-data request whose token maps below it, carries a value
the map does not name, or carries no such claim is refused with 401 and the
OAuth 2.0 step-up challenge of RFC 9470 §3:
WWW-Authenticate: Bearer realm="ferroehr", error="insufficient_user_authentication",
error_description="patient data requires authentication at assurance level substantial or higher",
acr_values="http://eidas.europa.eu/LoA/high http://eidas.europa.eu/LoA/substantial"
acr_values lists every mapped value at or above the minimum, so a client can
send the user back to the identity provider with that request. EHDS Annex II 3.1
asks an EHR system used by health professionals for reliable identification and
authentication of them; Implementing Regulation (EU) 2026/2099 Art. 6(3) sets
substantial for cross-border exchange, and high from 26 March 2032.
The natural person behind a token is the issuer’s to say. Each
[[auth.issuer]] declares its kind, and ferrohealth-smart classifies every
token by it and by the issuer’s profile: a persons token through a client
the CDR grants sign_in_persons is the person, a token through a client the
CDR grants act_for_persons is that client acting for the person the token
names, and an app-only token is a system. The server asks the policy grants
while it classifies the token, from the copy each replica holds, so a grant
takes effect on the next request. A persons token through any other
client is refused with 401. The access record names the person by the
profile’s person_key, and a delegated token as the client acting for that
person; see Audit trail.
What counts as patient data: every API route except the definition family
(/definition/...: templates, archetypes, stored-query texts), terminology,
the aggregate counts under /admin/report, and the admin routes that manage
configuration, the retention policy, templates and
stored queries. The list of exceptions is closed, so a route
added later is judged patient data until it is listed. The health family,
/rest/status, discovery and /management are outside the API and never
judged.
Basic credentials carry no assurance level and no issuer-asserted person.
With minimum set a Basic request for patient data gets the same 401 step-up
challenge; definition routes stay reachable with Basic. A Basic user is a
person, bound by its key ([[authz.party_binding.basic_user]]).
The assurance level is judged before RBAC, so a caller below the level learns
it must step up rather than that it lacks a role. A client token acting for a
professional is held to the same level as any other token: the acr it
carries is the one judged, so a client-credentials token needs your
authorization server to put the professional’s assurance level on it.
Two limits worth planning around
Plain-HTTP issuers are accepted on a loopback host only. The server reads the issuer’s metadata and keys over TLS, because over plain HTTP an attacker on the network could serve their own signing keys (RFC 8414 §6.2); there is no switch that admits a plain-HTTP issuer elsewhere.
Revocation latency equals the access-token lifetime. Tokens are validated
offline against the issuer’s published keys; the CDR calls no introspection
endpoint (RFC 7662 defines that mechanism but does not require a resource server
to use it), so a token revoked at the identity provider stays acceptable here
until its exp passes. That is deliberate: introspecting per request would put
the identity provider’s availability in the request path, and caching the results
only shortens the lag. The control is therefore the token lifetime, which your
authorization server owns: keep access-token lifetimes short (minutes, not
hours) if prompt revocation matters, and use refresh tokens for session length.
clock_skew_leeway_seconds adds at most its own value on top of exp.
Authorization
Authorization has three composable layers. The per-EHR EHR_ACCESS gate with
the access evaluator is the openEHR-grounded base and is always on; the coarse
role layer is active when authentication is enabled; the patient scope is
opt-in. A request must clear every active layer. Deployments serving SMART apps can
enable a fourth, token-scope layer on top; see
SMART App Launch.
Per-EHR access control (EHR_ACCESS)
Every EHR carries a versioned EHR_ACCESS object, the openEHR
access-decision authority for that record. A new EHR has no settings, and what
that admits is a server-wide choice:
authz.rbac.ehr_access_default | An EHR with no settings |
|---|---|
open (default) | reachable by any caller the coarse layers already admitted |
restricted | reachable only by authz.rbac.admin_role |
open is the default because it is what every existing deployment runs, and
changing it changes who can read existing records. restricted is object-level
default-deny, and it is the setting to reach for if your threat model
includes a caller enumerating record ids: a server-created ehr_id is a
time-ordered UUIDv7, so it is not even unpredictable, and the OWASP
Insecure Direct Object Reference Prevention
cheat sheet is explicit that an unpredictable identifier is not itself an access
control.
Note
Under
restricted, the admin role still reaches a setting-less EHR. That is deliberate: a plain deny would make such a record unreachable by everyone (including the operator who would author the settings that fix it) which is an outage rather than a control. Bind callers to patients with the patient scope below; this key decides only the default disposition.
Committing settings of the access_directives scheme switches that EHR to
explicit policy, and those settings always win over the server default,
in both directions. The settings are an ACCESS_DIRECTIVE_SETTINGS, a class
of FerroEHR’s draft access control package, and every coded value is a code
of the access control groups of FerroEHR’s terminology ferroehr-operations:
{
"_type": "EHR_ACCESS",
"name": { "_type": "DV_TEXT", "value": "EHR Access" },
"archetype_node_id": "openEHR-EHR-EHR_ACCESS.access_directives.v1",
"archetype_details": {
"_type": "ARCHETYPED",
"archetype_id": { "_type": "ARCHETYPE_ID",
"value": "openEHR-EHR-EHR_ACCESS.access_directives.v1" },
"rm_version": "1.2.0"
},
"settings": {
"_type": "ACCESS_DIRECTIVE_SETTINGS",
"default_access": {
"_type": "DV_CODED_TEXT", "value": "restricted",
"defining_code": { "_type": "CODE_PHRASE",
"terminology_id": { "_type": "TERMINOLOGY_ID", "value": "ferroehr-operations" },
"code_string": "restricted" }
},
"gate_keepers": [
{ "_type": "PARTY_SELF" },
{ "_type": "PARTY_RELATED",
"external_ref": { "_type": "PARTY_REF", "namespace": "demographic", "type": "PERSON",
"id": { "_type": "HIER_OBJECT_ID",
"value": "0190b3a2-5a3e-7c1d-9e2f-3b4c5d6e7f80" } },
"relationship": { "_type": "DV_CODED_TEXT", "value": "guardian",
"defining_code": { "_type": "CODE_PHRASE",
"terminology_id": { "_type": "TERMINOLOGY_ID", "value": "openehr" },
"code_string": "10" } } }
]
}
}
- Default access:
openadmits any caller the other layers admit.restrictedadmits the administrator (authz.rbac.admin_role), the gate-keepers, a caller with a live care relationship to the subject and a caller a consent permit names;consent_requiredadmits the administrator, the gate-keepers and a caller a consent permit names. Every other caller gets403withrefused-consent-required. The record’s person always reads their own record. An EHR Extract export by manifest (POST /message/export) passes the access evaluator for every EHR the manifest names before it reads any content, so one EHR the caller may not reach refuses the whole export. - Who writes the settings: a new
EHR_ACCESSversion is committed by a gate-keeper the current settings name, or by an administrator acting on the person’s instruction.PARTY_SELFnames the record’s person; any other gate-keeper names a party of the demographic service by itsexternal_ref, matched against thePERSONthe caller is bound to. With no gate-keeper, only an administrator changes the settings. Every other caller is refused with403. A gate-keeper commits changes with a CONTRIBUTION (there is no dedicatedEHR_ACCESSendpoint in the openEHR REST API). The controller commits them on the person’s instruction withPOST /ferroehr/rest/extensions/v1/admin/ehr-access, which names the EHR in its body, so it reaches an EHR a restriction hides, and reads every version withGET /ferroehr/rest/extensions/v1/admin/ehr-access?ehr_id=…. Every change is versioned and audited like all record content. - Who reads the settings: the administrator, the record’s person and the
gate-keepers. To anyone else the settings are absent, so a restriction stays
invisible to a provider (EHDS Art. 8): an AQL query returns no
EHR_ACCESSrow of the EHR, an EHR Extract leaves itsEHR_ACCESSout, and a CONTRIBUTION that commits anEHR_ACCESSversion reads as unknown (404). One caller more receives theEHR_ACCESSin an EHR Extract: the holder of anexport_ehr_extractgrant whosesubject_namespacecovers the EHR, such as a migration client, since the extract transfers the whole EHR and an import elsewhere must keep the person’s directives. - Every write is checked: a CONTRIBUTION, an EHR Extract import and an
admin archive load that carry settings are refused whole with
400naming the first defect: settings of another scheme (the removedFERROEHR_ACCESS_CONTROL_V1among them), a member the class does not declare, or a broken invariant of the draft package, named asCLASS.Invariant, such asACCESS_DIRECTIVE.Restriction_denies. - Unreadable settings: stored settings that do not read as the scheme
hold the EHR closed. A request that names the EHR is refused with
500, no query reaches it, and the server logs an error naming it. Only settings stored before the write check can hold an EHR. An administrator repairs a held EHR withPOST /ferroehr/rest/extensions/v1/admin/ehr-access/repair, body{"ehr_id": "…", "settings": {…}}: the new settings must pass the write check, the repair commits a newEHR_ACCESSversion with its own commit audit and contribution, and it writes an access record (ehr-access-repair:<versioned object uid>) naming the administrator. The repair is refused with409for an EHR that is not held; such an EHR changes its settings with a CONTRIBUTION. - Every replica decides by the committed settings: the commit of an
EHR_ACCESSversion writes the EHR’s settings, one row per directive and exception and one row per sensitivity label into side tables in the same transaction, and notifies every replica when it commits. Each replica holds a copy of each EHR’s settings and drops it on that notification, so a revoked gate-keeper or directive decides the next request on every replica. While a replica’s listener is down it reads the settings on every request, and a settings store that cannot answer is503. The first boot fills the side tables from the stored versions, andferroehr party-binding refillrebuilds them. - The access evaluator decides every request: see Access directives below.
- The default definition: every boot stores the archetype
openEHR-EHR-EHR_ACCESS.access_directives.v1.0.0when no definition of its id is stored, and never over a stored one. It constrains the settings toACCESS_DIRECTIVE_SETTINGSand its attributes; the definition upload validates an archetype that names a class of the draft access control package against the RM extended by that package. FerroEHR reads the settings by their codes, never by this id, so a deployment may use its own.
The scheme is a FerroEHR extension: openEHR mandates the EHR_ACCESS object
and its change control but publishes no concrete access-control scheme. The
decision also holds for AQL, ad-hoc and stored queries alike: data the caller
may not read contribute no rows, whether the query names the EHR in its
WHERE clause, in an EHR predicate, through the ehr_id parameter, or not
at all, as in a population query, and COUNT, LIMIT and OFFSET count only
the rows the caller reads.
Access directives
The access evaluator decides every request that reaches an EHR, after
authentication, the operation grants and the SMART scopes, by a fixed
procedure over three sets of facts: the person’s directives and labels in the
EHR’s EHR_ACCESS settings, the caller’s facts in the demographic service
(the operations, sensitivity clearances and permitted purposes its
capabilities grant, and the care teams it is a member of), and the
controller’s access policy. The first step that
refuses decides, and a deny overrides a permit:
| Step | What refuses | Answer |
|---|---|---|
| 1. Opt-out (EHDS Art. 10) | an opt_out directive, for an access service | 404, as for an unknown EHR |
| 2. Restriction (EHDS Art. 8) | a restriction directive, for a professional, a system or an access service, over the data it covers | 404, as for unknown data |
| 3. Consent deny | any other deny directive that applies; a representative a delegation directive names reads only what it permits | 403 refused-consent-denied |
| 4. Sensitivity | data whose label or classification the caller is not cleared for, and no applying permit names | 403 refused-sensitivity |
| 5. Care relationship | no live care relationship to the subject, where the access policy requires one | 403 refused-no-care-relationship |
| 6. Purpose | no declared purpose, or one the caller may not declare, where the access policy requires one | 403 refused-purpose-missing, 403 refused-purpose-not-permitted |
| 7. Default access | the settings’ default_access, or authz.rbac.ehr_access_default for an EHR with none | 403 refused-consent-required |
- Who is bound. The record’s person skips every step (EHDS Art. 3). A
representative is held to steps 1 to 3 and skips the others (Art. 4(2)).
An access service is a caller holding an
access_servicegrant or a verified caller of afederationissuer. - When a directive applies. Every attribute an
applies_toentry sets must hold for the caller: the party (its ownPERSONorAGENT, a care team it is a member of, the provider its client acts for, or aGROUPthat provider is a member of), a role it holds, thecarerelationship (a live care relationship), therepresentativeandproxyrelationships, or its caller kind. Itsoperations(read,write,export,query),purposesandtime_validitymust hold too, and itsdatascopes say which data it covers: objects, templates, root archetypes, categories (through the category map), sensitivities, origins and commit time. One level ofexceptionsof the opposite effect narrows it. - A fact that cannot be read never opens data. A
time_validitybound with no offset, a purpose the request does not declare, or a commit with no recorded origin is read as covered by a deny and not by a permit. - Emergencies. An access service that may override an opt-out and
declares one of
[audit] emergency_purpose_codesreads an opted-out EHR where the directive’semergency_overrideholds, unless it acts for the person (Art. 10(2)). The holder ofauthz.rbac.emergency_access_roledeclaring such a purpose reads data a restriction or a consent deny covers where itsemergency_overrideholds, and passes steps 4 to 7 (Art. 11(5)). A directive whoseemergency_overrideis false binds in every emergency, as an absolute opt-out of the Member State’s law does (recital 55). Each such access carries the emergency mark. - Every decision is a copy. The settings, the caller facts and the access policy are held on each replica and dropped on the notification of the commit that changes them, so a decision adds no database transaction. A named object is read for its template, archetype, origins and commit time only when a directive, label or classification of the EHR depends on them.
- Refusals. A
403names its code indetail, and withPrefer: return=representationin therefusalmember (problem types). Steps 1 and 2 say nothing.
The decision procedure, its order and its codes are FerroEHR’s own design:
RM EHR IM §EHR Access requires every decision to follow EHR_ACCESS, and
publishes no procedure.
Upgrading drops every stored EHR_ACCESS of the removed
FERROEHR_ACCESS_CONTROL_V1 scheme, with its history, and the next boot
gives each such EHR the default EHR_ACCESS with no settings, which the
server default governs. Commit new settings in the access_directives
scheme for the EHRs that had them. Upgrading also drops the Art. 8
restriction and Art. 10 opt-out registers below with their rows and their
admin routes: record each restriction and opt-out that stood again as a
directive.
Restriction of access by health professionals (EHDS Art. 8)
Regulation (EU) 2025/327 Art. 8 gives a person the right to restrict the access of health professionals and healthcare providers to all or parts of their data, and has the fact of the restriction stay invisible to healthcare providers. Art. 11(5) lets the restricted data be reached where necessary to protect the person’s vital interests, logged so the person can see it. No openEHR specification governs this; it is our own design.
- Recording it. A restriction is a
restrictiondeny directive of the EHR’s ownEHR_ACCESSsettings (theaccess_directivesscheme above). The controller records it on the person’s instruction by committing a newEHR_ACCESSversion withPOST /ferroehr/rest/extensions/v1/admin/ehr-access, for the whole EHR (nodata) or for the versioned objects itsdata[].objectsname, and lifts it by committing a version without it (the routes).GET /ferroehr/rest/extensions/v1/admin/ehr-accessreads every version, so a lifted restriction stays in the history, and an EHR Extract carries the versions. A whole-EHR restriction covers data recorded after it too. - What the server reads of it. The access evaluator reads every
attribute of the directive for each caller (Access directives):
its
datascope,applies_to,operations,purposes,time_validityandexceptions. The event stream, which has no caller, withholds every object a restriction in force covers, and the whole EHR for adatascope beyondobjects. - What a professional sees. Restricted data reads as absent: a restricted composition or EHR answers 404 exactly as an unknown one does, a query leaves it out at every scope (and a query scoped to a restricted EHR answers as for an unknown EHR), an export skips it, a CONTRIBUTION lists none of its versions, the event stream withholds it, and a write to it is refused as a write to an unknown target. No status, header or count says that a restriction exists.
- What it does not change. Nothing is deleted, and storage and the controller’s own processing go on: the admin routes (dump, archive, erase, the registers) see everything. It is not the GDPR Art. 18 restriction of processing, which answers 403 and stops processing itself.
- The emergency override. A caller holding the role
authz.rbac.emergency_access_rolenames that declares one of[audit] emergency_purpose_codesreads the restricted data where the directive’semergency_overrideholds, and its access record carries the emergency mark. Either alone lifts nothing. Unset, nobody may override.
[authz.rbac]
emergency_access_role = "EMERGENCY"
[audit]
purpose_codes = ["TREAT", "ETREAT"]
emergency_purpose_codes = ["ETREAT"]
The grain is the versioned object, the whole EHR, or both. A finer grain (one entry inside a composition) is not built: an object is the unit the version reads, the queries and the exports already decide on, and splitting a composition would change what the stored, signed version holds.
Opt-out from the access services (EHDS Art. 10)
Regulation (EU) 2025/327 Art. 10(1) lets a Member State’s law give a person “the right to opt out from the access to their personal electronic health data registered in an EHR system through the electronic health data access services referred to in Articles 4 and 12”, and has the Member State “ensure that the exercise of that right is reversible”. Art. 10(2) lets the Member State admit “a healthcare provider or health professional” where processing “is necessary in order to protect the vital interests of the data subject or of another natural person”, even after an opt-out. No openEHR specification governs this; it is our own design.
FerroEHR ships the software part: a mark on the whole EHR that the callers you grant as the access services read as absent. Whether the right exists, how the person exercises it, and the rules and safeguards of Art. 10(2) are your Member State’s law and yours to apply. Where the Member State enforces the opt-out in its own services, leave the mark unused.
- Granting the access services. Your Art. 4 access service (the
person’s) and your Art. 12 health professional access service each hold an
access_servicegrant in the CDR: a capability of aROLEtheirACTORorPERSONperforms (Operational policy).[authz.grants] alloweddoes not allowaccess_serviceby default, so the opt-out holds for nobody, and recording one is refused with 400. A role a token names grants nothing here. - Recording and reversing it. An opt-out is an
opt_outdeny directive of the EHR’s ownEHR_ACCESSsettings, at most one, covering the whole EHR. The controller records it on the person’s instruction by committing a newEHR_ACCESSversion withPOST /ferroehr/rest/extensions/v1/admin/ehr-access, and reverses it by committing a version without it (the routes). The reversed opt-out stays readable as a past version, and a version without one is accepted whatever the configuration, so an opt-out can always be reversed. Itsemergency_overridefalse makes it absolute: no vital-interest override lifts it (EHDS recital 55). - What an access service sees. A request from a caller holding an
access_servicegrant reads the EHR as absent: a route that names the EHR or an object in it answers 404 as for an unknown EHR, a population query leaves its data out, a query scoped to it answers as for an unknown EHR, an export and the lookup by subject find no such EHR, and a write to it is refused as a write to an unknown EHR. - What it does not change. Every other caller reads the record as before:
your own care, through callers that hold no
access_servicegrant, and the controller’s admin routes. Nothing is deleted. It is not the Art. 8 restriction above, which reaches every professional route and leaves the person’s own access open. - The vital-interest override. An access-service caller that declares one
of
[audit] emergency_purpose_codesreads the EHR where the opt-out’semergency_overrideholds, unless it acts for the person (a SMARTpatient/grant or the patient claim), because Art. 10(2) names a healthcare provider or health professional. Its access record carries the emergency mark, and a route that names the opted-out EHR, in its path or in aPOST /message/exportmanifest, adds an access recordaccess-opt-out-override:ehr-wideagainst it. - The record. Each commit and each read through the controller’s route
is an access record on the EHR (
ehr-access:ehr-wide) naming the administrator.
[authz.grants]
allowed = ["commit_composition", "access_service"]
[audit]
purpose_codes = ["TREAT", "ETREAT"]
emergency_purpose_codes = ["ETREAT"]
Information a person inserts (EHDS Art. 5)
Regulation (EU) 2025/327 Art. 5 lets a person, or their representative, insert information in their own EHR through the access services. That information “shall be clearly distinguishable as having been inserted by the natural person or by his or her representative”, and the person “shall not be able to directly alter the electronic health data and related information inserted by health professionals”. FerroEHR keeps both rules at the commit. No openEHR specification governs who may change what, so the rules are our own design; the marker is the RM’s own.
- Who counts as the person. A bearer token with a
patient/scope and nouser/orsystem/scope (for examplepatient/composition-*.cruds), from an issuer in[auth.smart] patient_issuers. The SMART scope grammar reservespatient/for “applications acting in the context of a specific patient/EHR” anduser/for those acting for a logged-in practitioner, so a clinician’s app usesuser/scopes and keeps every professional right. The patient claim ([auth] patient_claim) does not make a caller the person, because a professional’s token in a patient’s context carries it too. The rule is the FerroHEALTH family’s strict answer, shared throughferrohealth-smart; the Art. 3(3) delay below asks its broad one. - Who counts as the representative. A person bound to their own
PERSONwho acts for the patient through a representation relationship FerroEHR has recorded (how a login is looked up), through apersonsissuer or the patient portal (representatives in the patient portal). The rules below hold for the representative exactly as for the person. - The marker. Every version and CONTRIBUTION the person commits records
PARTY_SELFwith noexternal_refasAUDIT_DETAILS.committer, the RM’s way to say the committer is the record subject (RM common, Audit Details). A representative’s recordsPARTY_RELATED, naming the representative’s ownPERSONand the coded relationship. FerroEHR writes this committer itself and refuses one the request states that differs, in theopenehr-audit-detailsheader or in a CONTRIBUTION body. Every read of the version carries it, an AQL query reads it withv/commit_audit/committer, the contribution list extension flags the change set withinserted_by_person, and the viewer names the committer “The person or their representative”. The marker is part of the stored version, so a dump and its restore keep it. - The composer. A COMPOSITION the person or the representative commits
names the person (
PARTY_SELF) or their representative (PARTY_RELATED) as its composer. Any other composer is refused with 403, so the person cannot present what they insert as a professional’s. - What the person may change. The person and their representative may
update and delete a version whose committer is
PARTY_SELForPARTY_RELATED. An update or a deletion of a version anyone else committed, a professional or a system, is refused with 403 and a body that names EHDS Art. 5, whether it comes as a direct write or inside a CONTRIBUTION. Nothing is written. The marker is in the version, so the rule holds whatever became of the access record of the write. - What a professional may change. A professional’s writes are unchanged. A professional may update or delete an entry the person inserted; the new version is the professional’s, which the person may then no longer alter. The person’s own versions stay in the version history.
Delayed access by the person (EHDS Art. 3(3))
Regulation (EU) 2025/327 Art. 3(1) gives a person access to their data “immediately after the personal electronic health data have been registered in an EHR system”. Art. 3(3) lets a Member State restrict that right “by delaying access to their personal electronic health data for a limited period of time until a health professional is able to properly communicate and explain to the natural persons concerned information that can have a significant impact on their health”. Recital 10 gives the example: a diagnosis of an incurable disease should come first in a consultation, not through an electronic channel. This is the opposite direction of the Art. 8 restriction above: the data is withheld from the person, never from a professional. No openEHR specification governs it; it is our own design.
FerroEHR ships the software part. Whether the delay applies, to which data and for how long is the Member State’s rule, and you configure it in the access-delay register, an admin register. It is off by default, so the person’s access stays immediate.
- What is held. With the register on, every new COMPOSITION whose category
(the audit category register, template first,
then the root archetype) is listed in the register’s
categoriesis held from the moment it is committed, for the register’smax_delay. Only the first version is held: a composition the person has already seen stays visible when it is amended, and a professional holds an amendment by hand if it needs explaining. A composition the person commits is never held from them. - Who it is held from. A request that may be the person’s own: a bearer
token carrying a SMART
patient/grant, or the patient claim ([auth] patient_claim). A token that carries either is treated as the person’s, whateveruser/orsystem/grant it also carries, so a mixed token is withheld from rather than shown the data too early. The rule is the FerroHEALTH family’s, shared with the other products throughferrohealth-smart. To that request a held composition reads as absent: a read answers 404 as for an unknown composition, a query and an export leave it out, a CONTRIBUTION lists none of its versions, and a write to it is refused as a write to an unknown target. - What a professional sees. Everything, as before. The hold changes no professional route, query or export.
- Releasing it. The treating professional releases a composition once it
has been explained, from the clinical surface with
POST /ferroehr/rest/extensions/v1/ehr/{ehr_id}/versioned_composition/{versioned_object_uid}/access-delay/release. The route takes the checks of a write to that EHR: itsEHR_ACCESSgate, the patient scope and the SMARTcomposition-update grant. A request that may be the person’s is refused with 403. The controller releases withPOST /ferroehr/rest/extensions/v1/admin/access-delay/release, and holds one by hand withPOST /ferroehr/rest/extensions/v1/admin/access-delay, for at most the access-delay register’smax_delay(the routes). - The limit. Every hold ends by itself when its period passes, released or not, because Art. 3(3) allows a delay “for a limited period of time” only.
- The record. Placing a hold, releasing it and its expiry are each an access record: the release names the professional who made it, and the server writes the expiry record within a minute of the limit passing.
- The person’s access trail (Art. 9). A record about a held composition
would tell the person a result exists. The subject-scoped ITI-81 read, the
one a patient portal serves the person’s own trail from, leaves out every
record that names a held composition, its hold included, until the hold is
released or expires; the records then appear unchanged, with their original
times. The filter is
ehds-logging’s, the FerroHEALTH family’s EHDS logging component. The controller’s unscoped read shows every record at all times.
Turning the section off makes every held composition readable to the person at once: the holds stay in the register, and no new one can be placed.
RBAC (role-based, coarse)
Every openEHR operation is classified as Public, Clinical, or
Admin, and a role model gates each class. Roles are plain,
case-insensitive strings. A Clinical operation needs an authenticated caller
and no role; the configured roles default to ADMIN (admin_role, every
Admin operation) and READONLY (readonly_role, refused on every write).
| Environment variable | Default | Meaning |
|---|---|---|
FERROEHR__AUTHZ__RBAC__ENABLED | true | the coarse role gate (active only when auth is enabled) |
FERROEHR__AUTHZ__RBAC__ADMIN_ROLE | ADMIN | role required for admin operations |
FERROEHR__AUTHZ__RBAC__READONLY_ROLE | READONLY | role marking a principal read-only: refused on every write |
FERROEHR__AUTH__ISSUER__0__ROLE_CLAIMS | ["roles","groups","entitlements"] | JWT claim paths mined for roles, per issuer; a Keycloak issuer adds realm_access.roles |
FERROEHR__AUTHZ__RBAC__ROLE_ISSUERS | empty | the persons issuers whose role claims may grant the administrator and emergency roles; a token of any other issuer never holds them |
Roles come from the JWT claims listed in ROLE_CLAIMS, or from a Basic user’s
configured roles. The defaults are the carriers
RFC 9068 §2.2.3.1 names
for conveying authorization state (roles, groups, entitlements, of which
roles and entitlements are SCIM
attributes), the default every FerroHEALTH product shares. A claim path may be
dotted, so an issuer that nests them differently, such as Keycloak’s
realm_access.roles, is configuration rather than a code change; a claim
carrying a single string and one carrying an array are both accepted.
A Clinical operation needs at least one role of any name; an Admin operation
needs the admin role. A Basic user holds the roles its roles list names
and nothing else, so a user with none is refused every Clinical operation;
roles = ["USER"] satisfies the Clinical class and no Admin operation. A
bearer token whose SMART on openEHR resource scopes are all system/ scopes,
such as system/template-*.r, is a backend client and needs no role for a
Clinical operation: its scopes decide what it reaches. A user/ or patient/
token belongs to a person and still needs a role. The former user_role key is refused at boot.
Disabling RBAC restores authentication-only behaviour.
Important
The management surface is not configured here.
/management/*is governed entirely by[management.endpoints], one level per endpoint, and nothing under[authz.rbac]changes it. There is no global default beside it: an endpoint you do not name isoffand is not mounted at all.Each level means:
off, not mounted, answers404;private, any authenticated principal;admin_only, authenticated and holdingauthz.rbac.admin_role(the one place RBAC is consulted);public, no check at all, including no authentication.The consequence worth internalising:
prometheus = "public"is reachable by an anonymous caller whatever your RBAC settings say, because apublicendpoint is mounted outside the authentication layer. Lock the surface down by raising the levels in[management], and read the effective set back from/management/env(or from the boot log line that names every mounted endpoint and its level) rather than assuming.
Important
The OAuth2
scopeclaim does not grant roles. A scope grants a client delegated authority (RFC 6749 §3.3); it asserts nothing about the subject’s roles. Reading it as one also made the at-least-one-role check pass for every OIDC token, sinceopenidalone satisfied it. If your callers rely on a scope naming a role, move that role into one of the role claims above. Scopes remain on the principal and still drive SMART scope enforcement.
Note
The downloadable Compose quickstart deliberately runs with RBAC off and a single user, so every surface works out of the box (see Docker Compose). Turn the role gate on with
[authz.rbac] enabled = true(orFERROEHR__AUTHZ__RBAC__ENABLED=true) and give each principal an explicitroleslist.
A principal carrying the readonly_role (default READONLY) is refused on
every write operation (creating an EHR, committing a composition, uploading a
template, and any update/delete) even when it also holds granting roles such
as ADMIN (a restriction always overrides a grant). Reads and AQL queries stay
permitted, so a READONLY account is an authenticated, view-only principal. The
repository’s from-source development stack ships one such account
(ferroehr-readonly, password ferroehr) alongside ferroehr and
ferroehr-admin, with RBAC at its default enabled = true, so the separation
can be tried out; the downloadable quickstart file has neither (one user, no
role gate).
The patient scope
A deployment whose callers each act for one patient, such as a patient portal behind its own identity provider, binds each caller to that patient with an access-token claim. Fine-grained decisions about who may read what are the access evaluator’s, over the subject’s directives and the access policy, and take no key; the patient scope is an authentication binding on top of them.
| Key | Environment variable | Default | Meaning |
|---|---|---|---|
[auth] patient_claim | FERROEHR__AUTH__PATIENT_CLAIM | unset | The access-token claim naming the patient a caller is bound to. Unset or blank, no patient scope applies. |
[auth] patient_namespace | FERROEHR__AUTH__PATIENT_NAMESPACE | unset | The subject namespace (EHR_STATUS.subject.external_ref.namespace) the claim’s ids are issued in. |
With patient_claim set, every caller is held to the EHR whose subject the
claim names:
- A token without the claim is refused with
403. - An operation on another patient’s EHR is refused with
403before it runs, or, for a read whose EHR only the result names, after. That covers the EHR,EHR_STATUS, COMPOSITION, CONTRIBUTION and DIRECTORY operations and their item tags. The EHR Extract import routes are checked as EHR writes and the export routes as EHR reads; an export by manifest (POST /message/export) holds every EHR it names, and one EHR of another patient refuses the whole export. - An AQL query reads only the rows of the caller’s patient, whatever the query
scopes or projects, including a query that reads only the
ehrrow. - A subject-less EHR is in no patient’s scope. Without
patient_namespace, the claim names a subject by its id alone, so an EHR whose subject id another namespace also holds is refused, on a direct route and in a query. Withpatient_namespaceset, the claim names the pair of namespace and id.
Warning
The patient scope is fail-closed: a gate reached without an authenticated caller refuses, and a subject lookup that fails is a
500, or a503withRetry-Afterwhen no database connection could be obtained. It is never read as a permit.
Response security headers
Three surfaces, three honest answers: the set differs because what they serve differs.
The REST API carries, on every response including the transport-layer ones
(413 from the body limit, 408 from the timeout, 503 from the overload
bound, 500 from the panic handler), the health routes and the management
listener on its own port. The family server stack sets them outermost
(ferrohealth-server), each only where a response does not set its own:
| Header | Value | Why |
|---|---|---|
Cache-Control | no-store | responses carry patient data; the OWASP cheat sheet names no-store for exactly that. It does not affect openEHR’s ETag/If-Match concurrency control, which is a precondition mechanism, not a caching one |
X-Content-Type-Options | nosniff | stops a proxy or browser re-guessing application/json as something executable |
Referrer-Policy | strict-origin-when-cross-origin | request paths carry ehr_id and version identifiers; this keeps them out of cross-origin Referer headers |
Cross-Origin-Resource-Policy | same-site | refuses cross-site embedding of API responses |
X-Frame-Options | DENY | for the HTML this origin can serve (Swagger UI) |
Content-Security-Policy | default-src 'none'; frame-ancestors 'none' | the defensive minimum, applied wherever a response does not set its own; Swagger UI needs a real policy and brings one. The cheat sheet is explicit that CSP “might be meaningless in the response of a REST API that returns content that is not going to be rendered”, so this is not a policy pretending to govern scripts: it says nothing loads and nothing frames |
X-XSS-Protection and X-Powered-By are absent because the cheat sheet says to
remove them, and no Server header is sent at all.
Strict-Transport-Security: max-age=31536000 is sent only when FerroEHR
serves TLS itself ([server.tls]). RFC 6797 §7.2
requires a browser to ignore it over plain HTTP, which is how this server is
commonly reached behind a terminating proxy, and forbids a server to send it
there. Behind such a proxy, set it at the proxy or ingress that owns TLS.
includeSubDomains is left out, because FerroEHR does not decide for the hosts
beside it.
The viewer carries the FerroHEALTH console set instead, because it serves
HTML: a CSP that admits scripts and styles from its own origin alone
(script-src 'self'; style-src 'self', no nonce, no inline script or
style), Referrer-Policy: no-referrer and Cross-Origin-Opener-Policy: same-origin (the viewer chapter
lists them), with Cross-Origin-Resource-Policy: same-site from the API set
beside them. Its Cache-Control has one scoped exception to no-store:
FerroUI’s stylesheet, theme and scripts under /ferrohealth-ui/<version>/
are served no-cache, so the browser keeps them and revalidates them, and
they hold nothing clinical (the viewer reaches the CDR from its own server,
never from the browser). Every document carries no-store, because
documents carry patient data. An asset response that is not a served body
(a 404, a redirect) is never kept either.
The published documentation site cannot carry response headers at all: it is
static files on GitHub Pages, so its policy travels as a <meta http-equiv>
element, which is weaker by specification (frame-ancestors, report-uri and
sandbox are ignored in meta form). Its img-src admits one outside path,
https://raw.githubusercontent.com/FerroHEALTH/FerroEHR/, for the conformance
badges the Conformance workflow pushes. Anyone re-hosting these docs behind a
real web server should send the headers properly instead.
Request limits and rate limiting
Four different protections, four different statuses, and an operator should be able to tell them apart from the status alone.
Connection bounds: [server] header_read_timeout. The limit that applies
before a request exists, because a client that opens a socket and trickles
headers, or sends nothing at all, reaches none of the others: a client that has
not sent its request head in time, counted from accept, is disconnected, on the
plain and the TLS listener alike. On a kept-alive connection the bound counts
from the first byte of each later request head, and [server] idle_timeout
(two minutes by default) closes a connection that waits that long for its next request.
Keep it longer than the idle timeout of your clients (90 s for a Go client) and
of any load balancer in front, so they close an idle connection first.
Body size: [server] body_limit and [api] body_limit. Two
tiers: the routes that accept bulk by design (template upload and
/message/import) take the listener’s limit, and the clinical surface the
narrower [api] one when it is set. Over-limit is 413. The listener’s
default is the family’s 1 MiB; a deployment that uploads operational
templates raises it (the chart and the Compose files set 64 MiB), and one whose
compositions embed large DV_MULTIMEDIA data raises the clinical tier
deliberately.
Request rate: [server.caller_rate], unset by default and set by the chart
and the Compose quickstart. It sits inside authentication, keyed on the
authenticated subject, because a hospital behind one NAT is a single address and
address-keying a clinical API would throttle a whole site for one busy client.
Refusal is 429 with Retry-After.
Concurrency: [server] max_concurrent_requests, the admission bound.
Refusal is 503 with Retry-After; the health routes are never refused.
So: 503 means the server is full right now, 429 means you are asking too
fast, 413 means your payload is too big. Full key tables are on the
configuration page.
If you benchmark this server, turn the rate limiter off first, or you will
measure the limiter. Our own measurement lanes compose an overlay that disables
it, and both instruments refuse to write a record if the server answered any
429: a performance number that is really a configuration key is worse than no
number.
Operational surfaces: what is reachable, and by whom
Everything reachable without a credential is listed here, with the reason it
is public. Every other route answers 401 to a request without one, and a
test drives every mounted route to keep this list closed. A public answer says
only what a client or probe needs; the detail behind it is on the
authenticated /management surface.
| Surface | Default | Why it is public, or how it is gated |
|---|---|---|
/health, /health/liveness | always on, unauthenticated | Orchestrator probes carry no credential. Liveness answers {"state":"up"} with no I/O behind it; /health answers the readiness status with the state alone. |
/health/readiness | always on, unauthenticated | An orchestrator probe: 200 while ready, 503 while the process boots or drains or an indicator is down. The body is the state, the phase and each indicator’s name and state, nothing more. The detail is /management/health. |
{rest root}/status | always on, unauthenticated | A documented client contract: status, server version, ITS-REST version, timestamp and the deployment profile. The licence, the deployment gaps and the support period are /management/status. |
{rest root}/.well-known/smart-configuration | mounted only with SMART on | SMART App Launch service discovery, read before the client holds any token (ITS-REST SMART App Launch, Service Discovery). |
OPTIONS {base path} | always on, unauthenticated | The ITS-REST System API’s options manifest, which its released OpenAPI document declares without security. |
{rest root}/swagger-ui, {rest root}/api-docs/* | private (api.openapi_ui) | Public only if you set public; admin_only and off are the other levels. |
/management/* | not mounted at all (management.enabled = false) | With the master switch off, every route is 404. |
/management/{info,metrics,prometheus,env,loggers,flamegraph,health,status} | each off individually | Even with the master switch on, each endpoint stays unmounted until you name a level for it. There is no global fallback: silence means off, so a surface this privileged opens one endpoint at a time, by name. |
management.listen | unset (shares the API listener) | Set it to serve ops introspection from its own listener on its own port. It binds all interfaces and always stays plain HTTP even with [server.tls] on, so treat it as an internal surface and keep it off any publicly routed port; the interface half of the separation is your network’s, not this key’s. Under deployment.profile = "production" setting it opens the plaintext_listener gap, so the server refuses to start unless the gap is accepted by name. |
env and flamegraph deserve particular caution: env renders the
effective configuration (redacted, but still configuration), and flamegraph
starts a CPU profiler on request, which is both a disclosure and a
denial-of-service lever. Both are off until you name a level, and the profiler
additionally caps the window and sampling frequency, refusing an out-of-range
request rather than clamping it silently.
Secrets: mount files, never bake values
Every secret this server reads has a *_file sibling, and the loader reads and
trims the file at startup. Exactly one of a pair may be set; both is a boot
error naming the pair:
| Secret | File sibling |
|---|---|
| the database DSN, per storage domain, and the credential that prepares the schema | database.url_file, database.<domain>.url_file, db.migrate_url_file |
| a Basic user’s Argon2 hash | auth.basic.users[].password_hash_file |
| the PGP signing-key passphrase | record.signing.key_passphrase_file |
| a terminology OAuth2 client secret | [terminology].oauth.client_secret_file |
| the object-store secret key | multimedia.secret_access_key_file |
| the national-identifier root key | privacy.identifier_protection.key_file |
(The TLS certificate_file / client_ca_file settings and a static key
set’s auth.jwks_file are paths by nature and have no inline form at all,
which is the same property arrived at from the other direction.)
That is deliberately the shape Docker Secrets and Kubernetes Secrets deliver: a file mounted into the container. So the recommended posture needs no extra machinery.
services:
ferroehr:
environment:
# Point the key at the mount path; the VALUE never appears anywhere.
FERROEHR__RECORD__SIGNING__KEY_PASSPHRASE_FILE: /run/secrets/signing_passphrase
secrets:
- signing_passphrase
secrets:
signing_passphrase:
file: ./secrets/signing_passphrase.txt # or `external: true` in swarm
Why files rather than environment variables: an environment variable is readable
from /proc/<pid>/environ by anything in the container’s namespace, appears in
docker inspect output, is inherited by every child process, and is routinely
captured whole by crash reporters and process listings. A mounted file is none of
those, and it can be rotated without recreating the container.
Two properties worth knowing because they are not obvious:
- Redaction is a property of the type, not a list. Secret-bearing fields are a
Secret/SecretUrlnewtype whoseDebugand serialization render***, so a new secret key cannot be forgotten by a per-endpoint redactor:/management/envandferroehr config checkshow***because the type does, not because something remembered to hide it. A Basic password hash in[auth]is asecrecysecret of the shared crate’s section, rendered***the same way. - A Kubernetes
Secretis base64, not encryption. The cheat sheet is blunt about this: Secrets are stored unencrypted in etcd by default. Enable encryption at rest or use an external manager; the chart mounts whatever you give it and cannot make an unencrypted store safe.
Warning
The downloadable quickstart carries an inline Argon2 hash for its throwaway
ferroehruser, because a self-contained demo file cannot reference a secret you do not have. That is the one place a credential appears in our own artifacts, and it is a development credential by construction; replace it before any real use.
Verifying what you pulled
Release binaries, container images and the Helm chart carry signed build provenance, SBOMs and checksums, so you can establish that the bytes you are about to run came from this repository’s own pipeline and see what went into them. The commands, the SBOM formats, the SLSA levels claimed per artifact, and the published VEX justifications for scanner findings are all in Verifying releases. Enforcing image provenance at admission time inside a Kubernetes cluster is covered separately, in Images: build, provenance, scanning.
The pseudonymisation boundary
The pseudonymisation boundary separates a record from the person it is about, and it is enforced by PostgreSQL grants rather than by the server’s own routing: code that reaches for the wrong schema is a bug that can be fixed, while a database role able to read two domains defeats the separation however correct the code is.
GDPR Art. 4(5) defines pseudonymisation as processing where attributing data to a person requires additional information “kept separately and subject to technical and organisational measures”, and Art. 32(1)(a) names it a security measure for health data. EDPB Guidelines 01/2025 require that separation to hold against internal actors, operators with database access included.
Two domains hold the two parts, each behind its own role:
flowchart LR
server["FerroEHR server"]
server -->|ferroehr_clinical| ehr[("clinical<br/>versions and nodes,<br/>keyed by an opaque subject pseudonym")]
server -->|ferroehr_party| demo[("party<br/>parties, and national identifiers<br/>sealed under a per-domain key")]
server -->|audit writer| audit[("audit<br/>ATNA record repository")]
ehr -. barred .- demo
Read one domain and you hold a clinical record whose subject is an opaque
identifier, or a set of people with no records attached. Only the two together
re-identify anything, and no credential the server uses holds both. The
migrations create the roles, grant each its own schema, and revoke every
other domain explicitly, in both directions; each role is NOINHERIT and a
member of no other, so a grant cannot arrive through a membership.
The boundary is checked at startup, not assumed: the server reads the catalogue for every table, view, sequence and function each role can reach in a domain it does not own, and refuses to serve if it finds one, naming the role and the object. A misconfigured grant is a failed boot, not a silent weakening.
Two limits are worth stating plainly. The clinical schema holds a pseudonym
only when [privacy] subject_namespaces declares the namespaces a subject
reference may draw from — left unset, whatever a client sends is what gets
stored, and no schema split saves you from a national identifier written into
the clinical side; see
Privacy and identifiers. And the split is a
schema split by default: giving the demographic domain its own
[database.party] url is what turns it into a credential split, which is the
deployment step described in
Operations.
Resolving across the boundary
One question needs both domains at once: which record belongs to this
person? The server answers it in the application, over two connections, never
in the database. An EHR names its subject in its own
EHR_STATUS.subject.external_ref, which the ehr relation copies into its
subject columns on every EHR create and EHR_STATUS update. A cohort and the
AQL demographic join read the parties on the party connection and the EHRs whose subject names them on the clinical connection,
with a second search path and, when [database.party] url is set, a second
database role. FerroEHR matches, links and merges no patients, and offers no
lookup from a national identifier to its party.
No statement performs the join, because no credential could: the
clinical role holds no grant in party and the party role holds none in
clinical, both revocations are explicit and in both directions, and the boot
check refuses to serve a database where either has been given one. The
crossing exists as an application step that can be audited, rather than as a
query anyone holding one password could write.
Every crossing records an access event in the linkage domain, naming who
asked, the purpose of use they declared, and how many EHRs it reached. A miss
is recorded like a hit: it says someone asked whether this deployment holds a
record for that person. The event deliberately does not name the EHR that
came back. A record pairing a party with its EHR would make the audit trail a
map from parties to their EHRs, which the split exists to withhold.
Looking an EHR up by subject (GET /ehr?subject_id=…&subject_namespace=…)
does not cross the boundary. That operation matches the EHR’s own
EHR_STATUS.subject.external_ref, which is the opaque pseudonym the privacy
layer already constrains, so it resolves a pseudonym rather than an identity
and reads no party. It records a linkage-domain access event all the same,
naming the subject namespace and the EHR it found, because who resolved a
subject to a record is worth knowing wherever it happened.
The lookup puts the subject identifier in the URL, because ITS-REST passes it
as a query parameter. FerroEHR keeps it out of everything it writes: the
request log and every trace span record the path and the matched route without
the query string, and the 404 for an unknown subject names only the
namespace. A reverse proxy or load balancer in front of FerroEHR sees the whole
URL, so configure it not to log query strings on this route, or not at all.
FerroPIX as the EHR index provider (IHE PIXm, planned in
#3380) resolves a
patient identifier to an EHR without putting it in a FerroEHR URL.
Declaring the posture
The separations above are each a configuration key, and a deployment that has
made none of them is indistinguishable from one that has made all of them
until something goes wrong. The top-level deployment.profile key
(configuration) makes the
posture explicit: production refuses to start while a separation is missing
and not accepted by name, and reads the cluster each pool reached from
pg_control_system() rather than trusting the DSN text; sandbox, the
default, names every missing separation on the banner, in the boot log and on
GET /management/status, reports the profile on GET /rest/status, and must
not hold real patient data. The database keeps
its own line of defence for the subject pseudonym too: once
privacy.subject_namespaces is declared, a trigger on ehr refuses a subject
reference that is not a UUID, whichever code path or session writes it.
One instance, one organisation
FerroEHR is single-tenant, and that is where openEHR puts the boundary. BASE
architecture_overview/master06-design_of_the_ehr.adoc §The EHR System defines
a system as “a distinct logical repository corresponding to an organisational
entity that is legally responsible for the management and governance of the
healthcare data contained within”, and says it is “distinct from any underlying
virtualisation infrastructure or cloud computing facility, which may house
multiple logical EHR systems in a multi-tenant fashion”. Multi-tenancy belongs
to the layer that hosts several systems, not inside one of them.
So several organisations are served by several instances: one instance, one
database, one set of domain roles each. That is a stronger boundary than a row
predicate — a defect in a query cannot cross it, because there is nothing to
cross — and it is what the §System Identity rule needs, since system_id
“becomes embedded in the version identifiers of committed – and possibly
signed – content” and “cannot easily be changed afterwards”. One system_id
shared across organisations mints version identifiers that cannot tell the
responsible parties apart.
There is therefore no tenant column on any relation, no row policy, no session
variable to set and no [tenancy] configuration. What separates the clinical
record from the identity of its subject is the pseudonymisation boundary above,
which is a different question and stays.
Version signing
Every version the server commits can carry a VERSION.signature, computed
inside the write transaction over the canonical form of the version itself.
Signing is on by default in digest mode, and read-time verification of
the server’s own signatures defaults to strict, so a served version that no
longer matches its stored signature is a 500 rather than a silently served
record.
The chapter Version signing covers the mechanism in two
pages: Digest signing (what is signed, when, what the
stored value proves, and how to reproduce it yourself) and
PGP signing (key configuration and rotation, client-supplied
signatures, and the signature an import wrapper carries). The [record.signing] keys
are in the configuration reference.
ATNA audit trail
Separately from openEHR’s own provenance, FerroEHR keeps an IHE ATNA
security audit trail of API access: on by default, persisted in the
local Audit Record Repository (the dedicated audit PostgreSQL schema),
rendered in both official formats (FHIR R4 AuditEvent per IHE BALP, and
the DICOM PS3.15 audit message for the classic syslog feed), retrievable via
the RESTful-ATNA ITI-81 FHIR search, and optionally forwarded to an
external ARR over syslog and/or the ITI-20 FHIR feed. Node authentication
(ITI-19) is available as native mutual TLS on the listener.
Stored records are tamper-evident: each is linked into a SHA-256 hash
chain maintained by the database, the table refuses every rewrite path except
the forwarding stamp, and SELECT * FROM audit.verify_audit_chain() names any
record that was modified or removed. That is detection, not prevention: the
controls that make it hard to forge wholesale are the least-privilege database
role and the off-box sinks.
The full chapter (record content, sinks, tamper evidence, the ITI-81 search,
fail-mode semantics, and mTLS) is Audit trail (IHE ATNA);
every [audit] key is in the
configuration reference.
Note
The ATNA trail is orthogonal to openEHR’s own
CONTRIBUTIONandAUDIT_DETAILS, which the server always writes in the same transaction as every change. openEHR audit records what a version says about its own authorship; ATNA records security surveillance of API access. Both coexist. Identified data never enters telemetry (metrics, traces, logs), so the audit trail is the single place where access to identified data is recorded; see Operations.