Enterprise identity providers
FerroEHR does not manage users. There is no user table, no user API, and no plan to add one: identity administration is delegated to your identity provider (IdP), and the CDR consumes standard OAuth 2.0 bearer tokens. This page records that posture and walks through connecting an identity provider: the generic standards path first, then Microsoft Entra ID (Azure AD), AD FS, Okta, Keycloak, a SAML identity provider behind one of them, and the answer for plain-LDAP directories.
- The posture: users live in the IdP
- How the CDR consumes an IdP
- Who the caller is
- The generic standards path
- Microsoft Entra ID (Azure AD)
- AD FS (on-premises Active Directory)
- “We only have LDAP”
- Okta
- Keycloak
- A SAML identity provider through Keycloak or Entra ID
- Just-in-time creation
- Serving SMART apps
The posture: users live in the IdP
A clinical data repository is the wrong place to store credentials. A user store would make the CDR an authentication product (password lifecycle, lockout policy, MFA, recovery flows, and the largest new attack surface the product could grow) duplicating what a dedicated IdP already does under your existing governance. So the split is deliberate and permanent:
- The IdP owns identities: accounts, passwords, MFA, group/role membership, lifecycle (joiners/movers/leavers), and session policy.
- The CDR owns authorization: it validates the token, mines roles from its claims, and enforces RBAC/ABAC and per-EHR access control on every request.
The HTTP Basic user list in ferroehr.toml holds persons only, and it is not
a user store: each Basic user maps to the PERSON that carries its binding
key, which the identity provider provisions through SCIM
(bootstrap and migration). A
machine authenticates with OAuth 2.0 client credentials and is granted what
it may do in the CDR (Operational policy),
and most people authenticate with bearer tokens
from the IdP.
Note
The viewer follows the same rule: it authenticates against the same credentials the CDR accepts (the same OIDC issuer, or Basic) and has no user-management screens. To create, disable, or re-role a user, use your IdP’s own administration surface.
How the CDR consumes an IdP
Three things do all the work:
- Token validation (
[auth]): the server reads the issuer’s metadata and key set at boot and validates each bearer token’s signature (asymmetric algorithms only),iss,exp/nbf,audandtyp; the audience list is mandatory, so a server with none refuses to boot rather than accepting another service’s token. See the bearer settings table. - Role mining (
[[auth.issuer]]):FERROEHR__AUTH__ISSUER__0__ROLE_CLAIMS(default["roles","groups","entitlements"], the RFC 9068 §2.2.3.1 carriers; a Keycloak realm addsrealm_access.roles) names the JWT claim paths whose values become the caller’s roles for the role layer. A path may be dotted to walk nested claims, and a claim holding a single string is accepted as readily as an array. - SMART on openEHR scopes: every route requires a scope from the
token’s
scopeclaim (user/composition-*.cruds,user/aql-*.sand so on; see SMART App Launch). Your IdP has to mint them, for example as Keycloak client scopes assigned to the client. A token with roles and no SMART on openEHR scope authenticates and is then refused with403on every route.
Everything below is those three pointed at a different issuer.
Who the caller is
ferrohealth-smart classifies every token by its issuer’s kind and
profile, and the server acts on the kind:
- A person signs in at a
personsissuer through a first-party client, a client the CDR grantssign_in_persons, or with HTTP Basic. The login is bound to thePERSONcarrying its key, and the person commits under thatPERSON. - A delegated person reaches the server through a client or an RFC 8693
actor the CDR grants
act_for_persons. The token’s subject is the person, so the request is bound and committed exactly as the person’s own; the client and the actor do not change who committed. The access record carriesacting_mode = delegated, the client and the actor chain. - A Keycloak impersonation is a delegated person. Keycloak 26.8 puts the
administrator who impersonates a user into an RFC 8693
actclaim of every token of the impersonation session,{"sub": <the administrator's user id>, "preferred_username": …}, which “is always present and cannot be disabled” (Keycloak 26.8.0 release notes, Track impersonation across token lifecycle and downstream services). An impersonation is therefore refused like any undeclared actor, unless the CDR grants the administratoract_for_personson anACTORcarrying its user id as aclient_ididentifier under the issuer. Then the request is bound to the impersonated user and commits as that user, and the access record names the administrator as the actor (EHDS Annex II 3.2(b) asks for the natural person who accessed). Keycloak’sactnames no issuer, so the actor is recorded under the token’s issuer. Theimpersonatorclaim (id,username) of Keycloak’s built-in IMPERSONATOR_ID and IMPERSONATOR_USERNAME session note mappers repeatsactand decides nothing. To refuse every impersonation, add those mappers and setimpersonation_marker = "impersonator"on the issuer: a token carrying the claim is refused before any actor is read. A Keycloak older than 26.8 writes noact, so there the marker is the only way to see an impersonation at all. - A guest, by the profile’s
guestmarkers (Entra ID marks one withacct = 1or anidpother than the issuer), is refused with403(refused-guest) unless the issuer’s[[auth.party]]table setsguests = true. Admit guests only for people acting under your own responsibility (GDPR Art. 9(3) and Art. 29), such as contractors. - A system caller is an app-only token by the profile’s
app_onlymarkers:subequal to the client claim underrfc9068,idtyp = appwithoutscpunderentra, and the listed service-account subjects underkeycloak. A Basic user is never one. A system caller acts for no person, so it holdssystem/scopes only, and a token with auser/orpatient/scope is refused with403. It reads under itssystem/scopes. It commits into an EHR only as a client the CDR grantscommit_composition: anACTORcarrying itsclient_idand performing aROLEwhose capability grants it (Operational policy), under the committerPARTY_IDENTIFIED{name = <client>, identifiers = [{issuer = <iss>, id = <client>, type = "client"}]}with anexternal_refto thatACTOR. The grant decides the templates it writes, the facilities it writes at and whether it relays a person’s act or registers a device’s; an import or an export needs a grant of its own. - A verified external person or organisation of a
federationissuer is admitted only under the federation agreement its partner holds in the CDR for its accessor kind, the partner being the party that carries the token’s issuer andclient_idas aclient_ididentifier (Operational policy), and refused with403without one or under the other accessor’s. Its rights come from the agreement, never from a role:- it holds only the
patient/scopes the agreementreads(besideopenid,profile,fhirUser,online_accessandlaunch), so a token with any other scope is refused, and it reaches only the EHR of its launch context, which needs the issuer in[auth.smart] patient_issuers; - it is an access-service caller by its kind, so an opted-out EHR answers
404as an unknown one does (EHDS Art. 10(1)). Only an external person under an agreement withopt_out_overridereaches one, under an emergency purpose, recorded as an override; an organisation never does; - a read under an agreement with a
consentcondition needs the consent decision reference for the patient (Wabvpz Art. 1(j) and Art. 15a(1)): the token carries it in the claim orauthorization_detailsmember its[[auth.federation]]table maps toconsent.reference, as one string (a coded value refuses the token with401), and itspatient/grant holds it to the launch-context patient. A read without it is refused with403, and the access record carries the reference with the other external fields; - under an NL agreement, Wabvpz Art. 15f holds an insurer and an
occupational or insurance physician out. A caller whose
nl.roleis the UZI role 01.008 (bedrijfsarts) or 01.048 (verzekeringsarts) is refused with403asrefused-wabvpz-role, and a caller whosenl.organisation_typeis missing or is not a care provider type of Nictiz’sOrganisatieTypeCodelijstis refused with403asrefused-wabvpz-organisation-type, which is how an insurer is refused; - a
chainedorganisation request carries the requester’s correlation id in the claim or attestedauthorization_detailsmember its[[auth.federation]]table maps tocorrelation_id, as one string; a request without it is refused with403, and a request header never stands in for it; - a caller above its agreement’s
caller_rateis answered429withRetry-Afterbefore any patient lookup, a MyHealth@EU contact point’s included; - an external person commits only a COMPOSITION of a template the
agreement’s
writeslists; an organisation commits nothing, and neither attests or writes a demographic party. Neither deletes, except the discard of a dispensation described under the MyHealth@EU contact-point route; - an external person’s commit records the server’s committer, a
PARTY_IDENTIFIEDwith noexternal_ref: the asserted name as one string, the professional’shp_identifierunder the issuer"<country_code>:<issuing_authority_name>"with typehp_identifier, and the token’sissandsubwith typeoauth2. The country must be an upper-case ISO 3166-1 alpha-2 code, and the issuing authority is NFC-normalised with its white space trimmed and collapsed and may hold no:, control or bidi character. A missing or failing field is refused with403naming it. Map the authority with aconstantsource in the[[auth.federation]]table when the token does not carry it; - the COMPOSITION names the healthcare provider the token asserts in
EVENT_CONTEXT.health_care_facility, or with no context infeeder_audit.originating_system_audit.location: aDV_IDENTIFIERwith theprovider.healthcare_provider_identifierasidand theprovider.issuing_authority_nameasissuer. The server writes no facility and refuses a composition without it with422(EHDS Art. 13(4)). This is the domestic form; the MyHealth@EU contact-point form follows.
- it holds only the
- Attestations come only from a person bound to a professional
PERSON. A patient, a representative, a system caller and an unbound caller are refused with403(RM common master04 §Attestation).
The MyHealth@EU contact-point route
A federation issuer with contact_point = true in its [[auth.federation]]
table is a MyHealth@EU national contact point (NCPeH-A’s authorization
server). Its person agreement names the service it serves in ehdsi_service
(patient_summary, eprescription or orcd), and its issuer goes into
[auth.smart] patient_issuers. Every request runs with a sender-constrained token
(sender_constraint = "required"). On every patient-data route:
- The token carries the patient of the treatment relationship confirmation
in
ehdsi.patient.id, assystem|value, the patient identifier’s assigning authority and value, the form every family resource server reads. A token without it, or with a value of another form (an empty system or one with whitespace, or a value holding a control character,|,^,&,~or a backslash), is refused with403whosedetailopens withERROR_SEC_DATA_INTEGRITY_NOT_ENSURED(MyHealth@EU Requirements Catalogue 10.0.0 requirement 11.01.02), recorded asrefused-trc-missing, before the EHR index is asked. - The patient is resolved to its EHR through the deployment’s
EHR index, compared on the value and the
assigning authority, and the request must name that EHR: the route’s
{ehr_id}, or a query’sehr_id. The EHR stands in for the launch context the token does not carry (eHDSI XCA Profile 8.0.1 §4.2.1). - Another patient’s EHR, an EHR the server does not hold, an EHR an
opted-out patient’s record keeps out of reach, a TRC patient no EHR
belongs to, and a request that names no EHR all get one answer,
404of typetrc-patient-mismatchwhosedetailopens with the service’s*_NOT_FOUNDcode (ERROR_PS_NOT_FOUND,ERROR_EP_NOT_FOUNDorERROR_ORCD_NOT_FOUND), which the contact point answers as “No Data”. Each is recorded as arefused-trc-patient-mismatchsecurity event, once per request and never summarised (eHDSI XCA Profile 8.0.1 §4.2.2). - Where the agreement sets
discard, the person may discard a dispensation of a template itswriteslists, as a logical delete (DELETE /ehr/{ehr_id}/composition/{preceding_version_uid}), withindiscard_windowof its first commit (MyHealth@EU Requirements Catalogue 10.0.0, requirement 07.04). The eHDSI point of care is a name only, so the dispensation’sEVENT_CONTEXT.health_care_facilitymust carry every identifier the discarding token names its point of care by: theprovider.healthcare_provider_identifierunder theprovider.issuing_authority_name, and the same identifier under the issuerurn:oasis:names:tc:xspa:1.0:subject:organization-id, the HCPO’sorganization-id(eHDSI SAML Profile 10.0.0 §2.3). Any other discard is refused with403. - The committer of a contact point’s caller names the professional by the HP
Identity Assertion’s
NameID: aDV_IDENTIFIERwith the assertion’s issuer (ehdsi.assertion.issuer, NCP-B) asissuer, theNameID(ehdsi.professional.hp_identifier) asid, andhp_identifier:<NameID format>astype, such ashp_identifier:urn:oasis:names:tc:SAML:1.1:nameid-format:X509SubjectName, because one string under two formats names two identifiers (eHDSI SAML Profile 10.0.0 §2.1). The token’sissandsubfollow with typeoauth2, as on a domestic route. A discard is a logical delete under the same committer. - A contact point’s COMPOSITION carries, in
EVENT_CONTEXT.health_care_facility.identifiers, the provider’s identifier underprovider.issuing_authority_nameand, as a secondDV_IDENTIFIER, the HCPO’sorganization-idunder the issuerurn:oasis:names:tc:xspa:1.0:subject:organization-id. A commit without the second is refused with422; the server writes neither. - A token that carries permissions (
ehdsi.professional.permissions) records a dispensation and discards one only withPPD-046among them, as the code or itsurn:oasis:names:tc:xspa:1.0:subject:hl7:permission:URN (eHDSI SAML Profile 10.0.0 §2.5); otherwise it is refused with403.
The generic standards path
Every walk-through on this page configures the same three things: an issuer
of kind persons that signs your professionals’ access tokens, the
[[auth.party]] table their logins are bound through, and a SCIM client that
provisions their PERSONs. Configure them first against a standards-only
authorization server; the vendor sections after this one are the same
configuration through a preset (entra, keycloak, okta), each listing
the preset’s deviations with their sources. Every preset key can be set on
the issuer table, which wins over the preset.
-
The issuer. The
rfc9068profile is the default: an RFC 9068 access token withtypat+jwt, the client inclient_idand the scopes inscope.[[auth.issuer]] issuer = "https://as.example.com" kind = "persons" audience = ["ferroehr"]A person’s token is admitted only through a client the CDR grants
sign_in_persons: an administrator writes the client’sAGENT, carrying itsclient_idunder the issuer, and aROLEgranting the operation (Operational policy). -
The binding, on
sub. OpenID Connect Core 1.0 §5.7 namesisswithsubas the only stable identifier of an end-user, so therfc9068profile binds onsub. The[[auth.party]]table names the identifier the key is matched against:[[auth.party]] issuer = "https://as.example.com" identifier_issuer = "urn:example:staff-login" identifier_type = "uuid"An
email,phone_number,preferred_usernameornameis never a key. -
The SCIM client. Your authorization server issues the provisioning client an access token by the client credentials grant (RFC 6749 §4.4), or in exchange for a client assertion (RFC 7523 §2.2). Declare the authorization server as an issuer of kind
machines, and grant the clientscim_provisionin the CDR with thebinding_issuerof step 2. The SCIM client sends the key asurn:ietf:params:scim:schemas:extension:ferrohealth:2.0:User:loginIdentifier(RFC 7644). -
An onward caller. A service that calls FerroEHR for a signed-in professional, such as FerroBRIDGE, exchanges the professional’s token at the authorization server by RFC 8693 token exchange. Grant the service
act_for_personson theAGENTcarrying its client id (or, for an RFC 8693 actor, itssub) under the issuer: the request is bound to the professional, and the access record names the service.
Who is the committer shows what the server records for each of these callers.
Microsoft Entra ID (Azure AD)
Entra ID exposes a standards-compliant OIDC issuer per tenant.
-
Register an application (Entra admin center → App registrations). Note the Directory (tenant) ID and the Application (client) ID.
-
Define app roles (App registration → App roles): create roles named after the CDR roles you use (for example
USER,CLINICAL,ADMIN) and assign users/groups to them (Enterprise applications → your app → Users and groups). Entra puts assigned app roles in the token’srolesclaim. -
Expose an audience: either use the client ID as the audience or add an Application ID URI (for example
api://ferroehr). -
Point the CDR at the tenant issuer and mine the
rolesclaim:export FERROEHR__AUTH__ISSUER__0__ISSUER=https://login.microsoftonline.com/<tenant-id>/v2.0 export FERROEHR__AUTH__ISSUER__0__KIND=persons # Entra ID mints no RFC 9068 tokens (`typ` JWT, the scopes in `scp`), which # the `entra` profile reads. export FERROEHR__AUTH__ISSUER__0__PROFILE=entra export FERROEHR__AUTH__ISSUER__0__AUDIENCE=api://ferroehr export FERROEHR__AUTH__ISSUER__0__ROLE_CLAIMS=roles # Its roles may grant the administrator role. export FERROEHR__AUTHZ__RBAC__ROLE_ISSUERS=https://login.microsoftonline.com/<tenant-id>/v2.0Then grant your app
sign_in_personsin the CDR, on theAGENTcarrying its client id under the tenant issuer (Operational policy); a person’s token through any other client is refused with401. -
Verify: request a token for the app (any OAuth2 client credential or auth-code flow) and call the API. Read the status codes as a diagnostic:
Status What it tells you 200-familyroles arrived and the operation was permitted 401no credential, or one the server rejected (the body deliberately never says which) 403the token is valid but carries no role or SMART on openEHR scope the operation needs: a clinical call needs a matching scope and, unless every SMART on openEHR scope it holds is a system/scope, at least one role, an admin call needs the admin role and the product scope400the Authorizationheader itself is malformed; no credential was ever read503the CDR could not read your issuer’s key set again, so the token was never judged: check network egress, not the token
Important
A role must arrive in a role claim, not in
scope. The OAuth2scopeclaim grants a client delegated authority (RFC 6749 §3.3) and says nothing about the subject’s roles, so it is not a role source. If your IdP is configured to put role names inscope, map them intoroles(or another entry ofROLE_CLAIMS) instead.
Tip
Group-based deployments can emit the
groupsclaim instead and list it inROLE_CLAIMS, but group claims arrive as object IDs unless you configure group names, so app roles usually read better in policy.
Warning
Two configuration mistakes are boot errors rather than runtime surprises, so you will find them the first time you start the server: an issuer that is not an
httpsURL with no query or fragment, and an empty audience list. Both are deliberate: the second is what stops this server accepting a token minted for a different service. An issuer the server cannot reach at boot refuses the start too.
Binding and provisioning with the entra preset
The entra preset is the generic path with Entra ID’s deviations, each from
Microsoft’s Access token claims reference (claims) or Optional claims
reference (optional):
| Preset key | Value | Source |
|---|---|---|
person_key | oid | claims, oid: “The immutable identifier for the requestor”; sub is a pairwise value per application and never a key |
tenant_claim | tid | claims, tid |
token_types | ["JWT"] | claims, header typ “always JWT” |
scope_claim, app_only_scope_claim | scp (string), roles (array) | claims, scp and roles |
client_claims | ["azp"] | claims, azp |
app_only | idtyp = "app", and no scp | optional, idtyp; claims, scp “Only included for user tokens” |
guest | an idp other than the issuer, or acct = 1 | claims, idp; optional, acct |
expect | ver = "2.0" | claims, ver |
user_claims | ["acct"] | optional, acct, emitted only when the registration asks for it |
unstable_claims | upn, unique_name | claims, unique_name; optional, upn |
Binding on oid is FerroEHR’s choice on Microsoft’s “immutable identifier”
wording. For it to work, the app registration of FerroEHR’s API, and of
every service such as FerroBRIDGE that calls it, needs:
- the optional claims
acct(the guest marker: the preset requires it on every user token, so a registration without it is refused at the first token, naming the claim),idtyp(the app-only marker),given_nameandfamily_name, and theprofilescope thatoidneeds; "requestedAccessTokenVersion": 2in the manifest’sapiattribute (Understand the app manifest): FerroEHR accepts v2.0 tokens only, and a null value defaults to version 1.
Cross-tenant synchronisation and converted guests: a member-type user of
another tenant carries acct = 0, but an idp naming their home tenant. The
preset treats them as a guest by idp, so they bind only where the
[[auth.party]] table sets guests = true, and never as staff.
A person in more groups than fit in a token (the groups overage: “150 for
SAML tokens, 200 for JWT tokens”, claims) carries no groups claim, and the
login is refused with 403 (refused-groups-unavailable) unless the issuer
sets adapter = "idp-entra" with an [auth.idp.entra] table, which reads the
groups from Microsoft Graph. Provision only the groups assigned to the
application to stay under the limit.
Provisioning through SCIM. The non-gallery enterprise application, its
Tenant URL https://<host>/scim/v2/ and the steps on FerroEHR’s side are in
Provision from Microsoft Entra ID.
On the Entra side:
- Authentication. Use the OAuth 2.0 client credentials grant against your own authorization server, or Workload Identity Federation, in which Entra presents a signed client assertion your authorization server exchanges. Never leave the Secret Token blank: Entra then sends its own test token, which every non-gallery application of the tenant receives.
- Attribute mappings. Replace the tutorial’s
mailNicknametoexternalIdwithobjectIdtoexternalId, because a mail nickname “may not be unique in the directory” (Develop a SCIM endpoint). MapobjectIdtourn:ietf:params:scim:schemas:extension:ferrohealth:2.0:User:loginIdentifieras well, anduserPrincipalNametouserName. - Matching precedence. Set
externalIdfirst anduserNamesecond. - Remove every other attribute the FerroEHR mapping does not carry: “Schema discovery isn’t currently supported on custom non-gallery SCIM application” (Develop a SCIM endpoint), so Entra cannot learn FerroEHR’s schema and sends what its defaults name.
AD FS (on-premises Active Directory)
AD FS 2016+ speaks OIDC. This is also the supported path for on-premises Active Directory in general: front AD with AD FS (or another OIDC-capable broker) rather than pointing anything at LDAP.
-
Create an Application Group (AD FS Management → Application Groups → Web API template, or Server application + Web API for interactive clients). The Web API’s identifier becomes the token audience.
-
Issue role claims: on the Web API’s Issuance Transform Rules, add a rule mapping AD group membership to the
roleclaim (template: Send Group Membership as a Claim), one rule per CDR role. -
Point the CDR at the AD FS issuer and mine the
roleclaim:export FERROEHR__AUTH__ISSUER__0__ISSUER=https://adfs.example.com/adfs export FERROEHR__AUTH__ISSUER__0__KIND=persons export FERROEHR__AUTH__ISSUER__0__AUDIENCE=ferroehr-api # AD FS mints no RFC 9068 tokens: name the type and the claims its tokens carry. export FERROEHR__AUTH__ISSUER__0__TOKEN_TYPES=JWT export FERROEHR__AUTH__ISSUER__0__REQUIRED_CLAIMS=iss,sub,aud,exp export FERROEHR__AUTH__ISSUER__0__ROLE_CLAIMS=role export FERROEHR__AUTHZ__RBAC__ROLE_ISSUERS=https://adfs.example.com/adfsGrant your app
sign_in_personsin the CDR, as for Entra ID above.Discovery works out of the box (
https://adfs.example.com/adfs/.well-known/openid-configuration). -
Verify with the same status table as above:
401without a token,403with a token that lacks the required role.
Note
AD FS emits a single string for one role and an array for several; the role-mining layer accepts both shapes on any configured claim path.
“We only have LDAP”
The CDR does not speak LDAP, by design: LDAP bind would put password handling back inside the CDR. Front the directory with an OIDC-capable broker and connect that instead:
- Active Directory → AD FS (above) or Entra ID (if synced).
- Generic LDAP → Keycloak with LDAP user federation (the Keycloak example then applies verbatim), or any other OIDC provider that can federate LDAP.
The broker owns the LDAP bind; the CDR sees only signed tokens.
Okta
The okta preset reads Okta’s access tokens (Okta, OpenID Connect & OAuth
2.0 API, the reserved claims of the access token):
| Preset key | Value | Source |
|---|---|---|
person_key | uid | uid: “A unique identifier for the user” |
client_claims | ["cid"] | cid: “Client ID of the client that requested the access token” |
scope_claim | scp (array) | scp: “Array of scopes that are granted to this access token” |
app_only | no uid | uid “isn’t included in the access token if there is no user bound to it” |
token_types | none | the page names no typ, so an okta issuer fails to load until you set token_types to what your Okta server writes |
[[auth.issuer]]
issuer = "https://example.okta.com/oauth2/default"
kind = "persons"
profile = "okta"
token_types = ["<the typ header your server writes>"]
audience = ["api://ferroehr"]
Read the typ header of one of your server’s access tokens and set it in
token_types; the preset deliberately names none.
Keycloak
The keycloak preset reads Keycloak 26.8 access tokens: azp as the client,
scope as a string, typ JWT (confirm it against your own server), and no
app-only marker until you list your service accounts. Configure a realm for
binding as follows.
-
Two realms. An issuer has one
kind, so professionals sign in at one realm (kind = "persons") and patients at another (kind = "patients"). -
The binding on
sub. Keycloak’ssubis the user id, which no user can change. A user-profile attribute can be the key instead only when its Who can edit permission is Admin ("permissions": { "edit": ["admin"] }, Server Administration Guide, Managing user attributes). -
Service accounts. “A client’s service account is a user account with username
service-account-CLIENT_ID”, so itssubis a user id. List every service account of the realm by itssubin the issuer’sapp_only; the empty list refuses the issuer at load. On a realm with just-in-time creation an unlisted service account would be read as a person, so the list must be complete.[[auth.issuer]] issuer = "https://keycloak.example.com/realms/staff" kind = "persons" profile = "keycloak" audience = ["ferroehr"] app_only = [{ subjects = ["<the sub of service-account-lab>"] }] -
The audience for an onward caller. Keycloak’s standard token exchange requires “the requester client set as an audience in the
audclaim” of the subject token (Securing applications, token exchange). Add an audience mapper to the client scope your professionals’ tokens carry that puts the bridge’s or gateway’s client inaud, and let the onward caller name FerroEHR’s client id in theaudienceparameter. Grant the onward clientact_for_personsin the CDR. -
No impersonation on a binding realm. “Any user with the
impersonationrole in the realm can impersonate a user” (Impersonating users). Check that no user or group holds the realmimpersonationrole, or the fine-grained admin permissionimpersonate, and that no client holds the legacy token exchange’s impersonation permission; disable the legacy token exchange. Where an administrator must keep impersonation, add the built-in user session note mappers IMPERSONATOR_ID and IMPERSONATOR_USERNAME to the inbound client scope and setimpersonation_marker = "impersonator", so every impersonation is refused. Whether Keycloak 26.8 adds those mappers by default is not verified here; check the client scope. Keycloak 26.8 also writes an RFC 8693actclaim into every impersonation token, so an impersonator the CDR does not grantact_for_personsis refused even without the marker (Who the caller is). -
Realm hardening. On a binding or just-in-time realm: no self-registration, no social or other brokered identity provider without an explicit allow-list, and no automatic account linking (the first login flow’s “automatically set existing user”, or linking by email). Each of them would let a person choose which account, and so which
PERSON, a login reaches. -
SCIM. Keycloak 26.8 promotes its SCIM API to supported, as a service provider for its own realm’s users and groups (release notes, SCIM API (supported)). It provisions nothing outbound, so it cannot create FerroEHR’s
PERSONs orGROUPs: a deployment needs an upstream SCIM client, such as its identity governance or HR system, or just-in-time creation. Enabling Keycloak’s own SCIM adds a second SCIM endpoint to the deployment, which FerroEHR does not read.
A SAML identity provider through Keycloak or Entra ID
FerroEHR never sees SAML. It is an OAuth 2.0 resource server and validates only access tokens, so a SAML 2.0 identity provider reaches it through an authorization server that brokers it:
- Keycloak brokers it by Web Browser SSO (OASIS SAML V2.0 Profiles §4.1)
as the service provider, and issues its own OpenID Connect tokens after the
login. Set the identity provider’s Principal Type to the Subject
NameIDwith the persistent format (urn:oasis:names:tc:SAML:2.0:nameid-format:persistent, Keycloak’s default NameID Policy Format) or to an immutable attribute, so the brokered user’s Keycloaksubstays the same from login to login. Keycloak refuses a SubjectNameIDprincipal with the transient format. Map the name attributes togiven_name,family_nameandnamefor just-in-time creation, and the group attribute to the group claim. - Entra ID federates the SAML identity provider for its tenant, and the
entrapreset reads the tokens it issues as above.
Never bind on email, phone_number, preferred_username, name, upn or
unique_name, whatever the SAML assertion maps them from (OpenID Connect
Core 1.0 §5.7).
Just-in-time creation
An issuer can let a professional with no party work at their first login:
FerroEHR then creates a provisional PERSON from the access token and binds
the login to it, as
the configuration reference
describes. It is off until an administrator writes a create_at_login
grant for the issuer in the CDR, whose admission conditions read the
claims below
(Operational policy). What
each identity provider must do for it:
- Put the name claims in the access token. FerroEHR reads the person’s
data from the access token only (RFC 9068 §2.2.2 lets an authorization
server include resource owner attributes there), never from an ID token or
the userinfo endpoint. A generic issuer emits the OpenID Connect Core 1.0
§5.1 claims your mapped attributes name (
name,given_name,family_name). - Microsoft Entra ID (the
entrapreset): add the optional claimsgiven_nameandfamily_nameto the access token of your app registration and request theprofilescope: Entra documents both as v2.0 optional claims that “Requires theprofilescope” (Microsoft identity platform, Optional claims reference). Admit logins by group (anadmit_groupelement of thecreate_at_logingrant, holding an object id ofgroups) or by theidpclaim (anadmit_idpelement), which “records the identity provider that authenticated the subject of the token” and differs from the issuer for a guest (Access token claims reference). The key is the object idoid, neverupnoremail, which Entra calls mutable. - Keycloak (the
keycloakpreset): the built-inprofileclient scope maps the name claims; check that its mappers add them to the access token. Make the name attributes administrator-controlled as the key is: in the realm’s user profile, set the attribute’s Who can edit permission to Admin only ("permissions": { "edit": ["admin"] }in the JSON editor), which Keycloak defines as writable only from the administrative context (Server Administration Guide, Managing user attributes, Permission). A professional who could edit their own name could change what their first login writes.
The userName comes from user_name_claim, or the key when it is unset, and
never from a claim the user can change. SCIM completes a provisional PERSON
later: a client whose binding_issuer is the issuer’s identifier_issuer
finds it by userName, sets the externalId, and a complete PUT makes it
complete.
Serving SMART apps
If your IdP is also the authorization server for SMART App Launch apps, the same
[auth] issuer does double duty: the CDR validates the tokens those apps come
back with, and the discovery document it serves is built from that issuer’s
metadata, so the server it advertises to apps is the one it accepts tokens
from. See SMART App Launch.