SCIM provisioning
[auth.scim]: provisioning users and care teams from your identity provider.
[auth.scim]
FerroEHR is a SCIM 2.0 service provider (RFC 7644) at /scim/v2/, the
endpoint an identity provider provisions each professional through. It is off
by default.
| Key | Type | Default | Description |
|---|---|---|---|
filter_max_results | integer | 100 | The most resources one list response returns, which ServiceProviderConfig declares as filter.maxResults. At least 1. |
max_deactivations | integer | 100 | The most Users one client deactivates or deletes per window. Past it, a deactivation or deletion is 429 with Retry-After and logged at error. The count is kept in the database, so every replica shares one bound. At least 1. |
deactivation_window | duration | "1h" | The length of that window. At least "1min". |
contact_erasure_delay | duration | "0s" | How long after a User’s deletion the contacts of every version of its PERSON are erased (GDPR Art. 17). "0s" erases them in the deletion itself; at most "30d". |
max_group_members | integer | 5000 | The most members one Group holds. An add past it is 400 invalidValue. A membership change versions only the member’s PERSON, so its cost does not grow with the Group. At least 1. |
Who provisions is CDR data, read on every request: a provisioning client is
an OAuth client-credentials client of your own authorization server whose
ACTOR holds a scim_provision grant in force. The grant’s
binding_issuer is the identifier issuer of the binding keys the client
provisions: the identifier_issuer of an [auth.issuer.<name>.party] table
your professionals log in through. Its token_scope is the scope a token of the client
must hold; SMART on openEHR defines none for SCIM, so the value is yours to
choose. Each User belongs to the one client whose binding_issuer issues its
key, so no two clients’ grants name one. [authz.grants] allowed must admit
scim_provision. The first such grant is written with
ferroehr party-binding grant,
since no administrator can log in before the persons it provisions exist;
Operational policy has the
grant’s terms.
Every meta.location and discovery document names the resource by its URI
(RFC 7643 §3.1), under <public_base_url>/scim/v2 with
server.public_base_url
and server.base_path, so the table needs that key.
The table’s presence turns the endpoint on; it has no enabled key, and
setting one refuses the start. The start is refused when the table is present
without server.public_base_url, and when the party mapping
lacks what a User is written with: a default person template with a
user_name selector, and [authz.party_binding.professional_role].
[server]
public_base_url = "https://cdr.example.com"
[auth.scim]
[authz.grants]
allowed = ["commit_composition", "scim_provision"]
/scim/v2/ServiceProviderConfig answers without a token, so a client can read
the authentication scheme before it holds one. Every other path needs a
bearer token of a client that acts for nobody and holds a scim_provision
grant in force:
- no token, or one that does not verify, is 401 with
WWW-Authenticate: Bearer; - a person’s token, a client with no grant in force, a grant whose
binding_issueris not theidentifier_issuerof an[auth.issuer.<name>.party]table, or another client’s grant names too, and a token without the grant’stoken_scopeare 403, the last withWWW-Authenticate: Bearer error="insufficient_scope"(RFC 6750 §3.1).
Every refusal is an RFC 7644 §3.12 Error message in application/scim+json.
The client’s requests count against
[server.caller_rate] like any caller’s, so each
replica gives the client an allowance of its own, and past it a request is
429 with Retry-After. /scim/v2/Schemas serves the core User schema
reduced to userName, active and the SCIM attributes
[[authz.party_binding.person.attribute]] maps, and FerroEHR’s extension
urn:ietf:params:scim:schemas:extension:ferrohealth:2.0:User with
loginIdentifier, the attribute that feeds the binding key. /ResourceTypes
lists the User type at /Users, and the Group type at /Groups with
FerroEHR’s Group extension
urn:ietf:params:scim:schemas:extension:ferrohealth:2.0:Group and its
immutable boolean careTeam when Groups are served.
The two extension URNs are a deliberate deviation from RFC 7643. They sit
under urn:ietf:params:scim:schemas:extension:, the sub-namespace RFC 7643
§10.2 and RFC 3553 reserve for names IANA assigns, and neither name is in the
IANA “SCIM Schema URIs” registry (RFC 7643 §10.3). The reason is Microsoft
Entra ID: its provisioning client sends a custom attribute only under a name
of the form
urn:ietf:params:scim:schemas:extension:CustomExtensionName:2.0:User:CustomAttribute
(“For SCIM applications, the attribute name must follow the pattern shown in
the example”, Customize Microsoft Entra attribute mappings, vendored at
docs/specs/microsoft-entra/docs/identity/app-provisioning/customize-application-attributes.md
line 148). A schema id outside that namespace, which RFC 7643 §3 would allow,
leaves an Entra non-gallery application unable to send loginIdentifier, so
it could not provision anyone. The binding key fits no registered attribute:
userName is mutable, externalId is the client’s own identifier for the
resource (RFC 7643 §3.1), and the Enterprise User extension (§4.3) carries no
login subject. The two URNs are the provisioning contract of the FerroHEALTH
products, fixed in the same way as the /scim/v2 base path, and a client
writes them exactly as /Schemas lists them.
Users
A User is a PERSON of the default person template performing the
professional ROLE: SCIM (RFC 7643, RFC 7644) provisions a workforce. A
patient needs no provisioning, since their own token’s login binds their
PERSON. A representation is a PARTY_RELATIONSHIP of its own, written by
the patient, an administrator or a write_representation holder
(Regulation (EU) 2025/327 Art. 4(2)), and a User version that holds one in
its relationships is refused 422. This is FerroEHR’s own design. The client serves these operations (RFC 7644 §3):
POST /scim/v2/Userscreates thePERSONand itsROLEin one demographic CONTRIBUTION, under the client as committer, and answers 201 with the User, itsLocationand itsETag. The body carriesuserNameand the binding key inloginIdentifier;externalIdand every mapped attribute are optional. A version that fits its template in full iscomplete, and one that fits only with every lower limit at zero isincomplete, which the User’slifecycleStateandmissingPathsname. A User created withactive = falseis 400invalidValue.GET /scim/v2/Users/{id}answers the User with itsETag, the weak tag of its version, and 304 to anIf-None-Matchnaming that version.GET /scim/v2/Usersanswers aListResponse, an empty one with 200 when nothing matches.filtertakeseqandandoveruserName,externalIdandid; names and operators are compared in any case, and anything else is 400invalidFilter.startIndexandcountpage the result, at mostmax_resultsat a time.
The User’s userName, externalId and binding key are DV_IDENTIFIERs at
their selectors, issued by the client’s binding_issuer. A client sees only
its own Users, the ones whose key its binding_issuer issues: every other id
is 404 and absent from every list, as is a PERSON without a live
professional ROLE. The userName index spans every client, so a 409
uniqueness tells one client that a userName exists under another;
externalId is unique within one client. Every SCIM request is an access
record of the client, with the PERSON as its object.
A User is changed and removed through these operations:
PUT /scim/v2/Users/{id}replaces the User (RFC 7644 §3.5.1). A mapped attribute the body leaves out is cleared; the binding key andexternalIdare kept, and a left-outactivekeeps the lifecycle state.PATCH /scim/v2/Users/{id}applies the RFC 7644 §3.5.2 operations, value paths and areplacewithoutpathincluded, and commits the result as one version. The operation is read in any case, as the Entra ID client sendsReplace.DELETE /scim/v2/Users/{id}logically deletes thePERSONand its professionalROLEin one demographic CONTRIBUTION and answers 204. Every later request on the id is 404, the User leaves every list, and a new User may take itsuserName. The binding key stays behind as a tombstone: a login on it is refused as deprovisioned until the owning client creates a User with it again.
Each write answers with the User and its new ETag. An If-Match naming
another version is 412, a changed binding key is 400 mutability, and
a write without If-Match is accepted (RFC 7644 §3.14 makes entity tags a
MAY). active drives the lifecycle state of the PERSON (RM common
§Version Lifecycle):
| Current state | active in the request | Result |
|---|---|---|
complete or incomplete | true or left out | complete when the template holds in full, else incomplete |
complete | false | inactive |
incomplete | false | abandoned |
inactive | true | complete, or incomplete when the template does not hold |
abandoned | true | incomplete, then complete in a second version when the template holds |
inactive or abandoned | false or left out, with a change | 400 invalidValue: reactivate the User first |
inactive or abandoned | false or left out, without a change | 200, no new version |
An inactive or abandoned User is still read and found by a filter, so its
client can reactivate it. When the second version of an abandoned User
fails, the User stays incomplete and the same request completes it.
Roles
A User’s roles (RFC 7643 §4.1.2) are the roles the access policy’s
controller rules name. Each
value is one ROLE the User’s PERSON performs, of the professional role
template, whose name is the value coded in the terminology the client’s
scim_provision grant names, and whose time_validity starts on the day it
is added. The grant states which roles the client may hand out:
| Element | Value |
|---|---|
role_terminology | The terminology id the client’s role values are coded in, exactly one |
role | A role code the client may assign, one element per code |
A request whose roles names a code the grant does not list, or any role
when the grant names no role_terminology, is 403 and changes nothing.
A POST, PUT or PATCH makes the User hold exactly the roles its result
lists: a new value commits a new ROLE, and a removed one ends its ROLE
the day before (its time_validity gains the date of the removal as its
exclusive end) and drops it from the PERSON’s roles. The change decides
the next request on the replica that took it, and on every other replica
once the commit’s notification arrives, with no added transaction. A token’s
role claims never drive a controller rule. These ROLEs carry no
capability, so a SCIM client writes them, and an administrator alone grants
a capability. RFC 7643 sets no vocabulary for roles and RFC 7644 §2 leaves
the authorization model out: the mapping is FerroEHR’s own design.
The versions of a deleted User are kept for the record-keeping duties that
need the professional’s identification (GDPR Art. 6(1)(c), laid down in law
as Art. 6(3) requires: in the Netherlands BW 7:454(3), twenty years, and the
logging duty of the Besluit elektronische gegevensverwerking door
zorgaanbieders). Outside the Netherlands, name your national retention
provision. Enable the identity provider’s protection against accidental
deletions beside max_deactivations.
Only the attribution minimum waits for that horizon: the name, the binding key
and the identifiers, userName and externalId among them. The contacts
serve no attribution, so FerroEHR erases them (GDPR Art. 5(1)(e)): with
auth.scim.contact_erasure_delay = 0 the deletion removes the contacts of every
version of the PERSON in the same transaction, and with a period a sweep
that runs every minute removes them once the period has passed. The sweep
reaches every deleted PERSON whose binding key the binding_issuer of a
scim_provision grant issues, one that has ended included,
an administrator’s demographic DELETE included. Each version keeps its uid,
audit and contribution, and its node rows are derived again from the erased
body. A server signature on such a version is removed, because it was taken
over the content the erasure changed. Each erasure is an access record, a
delete of party:<id>#contacts. A login on the key is still refused as
deprovisioned.
Groups
When [authz.party_binding.group] names a display_name and
[authz.party_binding.membership] is set, /scim/v2/Groups is served beside
/Users, and /scim/v2/ResourceTypes lists the Group. A Group is a
demographic GROUP of the group template:
- its
displayNameis theGROUP’sPARTY_IDENTITY, unique across the live Groups after case folding, so a duplicate is 409uniqueness; - its
externalIdis aDV_IDENTIFIERat theexternal_idselector under the client’s group issuer: thegroup_identifier_issuerof the[auth.issuer.<name>.party]table whoseidentifier_issueris the client’sbinding_issuer, so the group claim of that issuer’s tokens matches it. When that table sets none, the group issuer is thebinding_issuerwith/groupsappended (urn:example:logingivesurn:example:login/groups), with any trailing/of thebinding_issuerdropped first. A deployment whose tokens assert groups setsgroup_claimand agroup_identifier_issuerin the table, and that value is the group issuer; - each member holds one inline
PARTY_RELATIONSHIPof the membership archetype, with itsPERSONassourceand theGROUPastarget, stored in the member’s own version (RM demographic §Party Relationships). NoROLEis created for a Group, and aPERSONin no Group hasrelationshipsVoid. - its
careTeam, in FerroEHR’s Group extension, says whether it is a care team: set at creation,falsewhen left out, and never changed (400mutability). A care team is served withcareTeam = trueand the extension in itsschemas; any other Group is served without either. A care team’sGROUPis named by the codedcare_teamand each membership by the codedmember_ofofopenehr_access(RM demographicPARTY.type()is thename), so its members are in the care of the patients under the team’s care. Creating one and changing its members needs the client’swrite_care_relationshipgrant besidescim_provision, and is 403 without it (Care teams provisioned over SCIM). The group template and the membership archetype must admit aDV_CODED_TEXTname, as the default definitions do.
A Group belongs to the client that created it; every other client gets
404. A member is a User of the same client: a member naming another
client’s User, an unknown id or a Group (nested Groups are not supported) is
400 invalidValue. What a Group allows stays with the token’s scopes and
roles; the access record lists the Groups the token names that the person
belongs to, and a Group in inactive or abandoned lists no member.
POST /scim/v2/Groupscreates theGROUPwith its members, if any, and answers 201 with the Group, itsLocationandETag.GET /scim/v2/Groups/{id}andGET /scim/v2/Groupsfilter witheqandandoverdisplayName,externalIdandid, andexcludedAttributes=membersleaves the members out. Each member is served with itsvalue,$refandtype.PATCH /scim/v2/Groups/{id}answers 204 with the newETag(RFC 7644 §3.5.2).addofmembersadds the listed members;removewith the filtermembers[value eq "<id>"]removes that member, andremoveofmemberswith neither a filter nor a value list removes them all.PUT /scim/v2/Groups/{id}replaces thedisplayNameand the members, keeps a left-outexternalId, and answers 200 with the Group.DELETE /scim/v2/Groups/{id}logically deletes theGROUPwith its memberships, and every later request on the id is 404.
Entra compatibility deviation. A remove of members that carries a
value list removes only the listed members, the request Microsoft Entra ID
sends. RFC 7644 §3.5.2.2 removes “the attribute and all values” when no
filter is specified; FerroEHR follows Entra only when the value list is
present.
A membership change is a new version of each member’s PERSON it touches,
in one CONTRIBUTION, and the GROUP gets no version; a change costs the same
whatever the Group’s size. The Group’s ETag is its GROUP version with a
membership revision that moves with every membership change, so it changes
whenever its members do (RFC 7644 §3.14). The member User’s ETag changes
too, since its PERSON holds the membership (RFC 7643 §4.1.2); its body does
not, because the User serves no groups attribute. Deleting a User deletes
the memberships its PERSON holds with it. Deleting a Group drops the
membership of each active member in the CONTRIBUTION that deletes the
GROUP. A GROUP an administrator set inactive or abandoned keeps its
version, since the version lifecycle draws no update of either state, and a
SCIM write to such a Group is 400 invalidValue.
Deactivated Users leave their Groups. The version lifecycle draws no
update of an inactive or abandoned PERSON (RM common master06 §Version
Lifecycle), so such a PERSON cannot take a membership change, and an
inactive PERSON binds to nothing. Setting a User’s active to false
therefore drops its memberships in the same version, and each Group’s
ETag changes. A membership of a care-team Group stays, as does every other
care relationship, since SCIM never changes one (Deprovisioning a team
member). Microsoft Entra ID often disables a user and then removes it
from its groups; the later remove finds nothing to remove and answers
204. An add naming an inactive or abandoned User is 400
invalidValue (“reactivate the User first”). A reactivated User belongs to
no plain Group until its client adds it again.
Provision from Microsoft Entra ID
Microsoft Entra ID provisions through a non-gallery enterprise application. FerroEHR validates the access token your own authorization server issues to it, so the steps split between the two.
-
Map the person template. The default party mapping maps
userName,externalId, the formatted, given and family name and the work email Entra sends. Set the person section only to map more, or to key the binding on the object id as the worked example there does.A value path such as
emails[type eq "work"].valueserves the value and itstype. FerroEHR holds one value pertypeand no preference among them, so/scim/v2/Schemasdeclaresprimaryread-only and theprimaryEntra sends is ignored (RFC 7644 §3.3). -
Grant the client. Grant its client
scim_provision, withferroehr party-binding grantor as an administrator through the Demographic API: the--issueris your authorization server, thebinding_issuerelement theidentifier_issuerof the[auth.issuer.<name>.party]your professionals log in through, and thetoken_scopeelement the scope its token holds. Setserver.public_base_urlto the URL Entra reaches. In the Helm chart, aconfig.auth.scimvalue also adds the/scim/v2path to the Ingress.ferroehr config checkrefuses a mapping the endpoint cannot serve. -
Federate Entra’s credential at your authorization server. Entra’s Workload Identity Federation presents a signed assertion, which your authorization server exchanges for a client-credentials access token (RFC 7523 §2.2). These checks are your authorization server’s, not FerroEHR’s, so verify each one there, as Microsoft’s “Workload Identity Federation for SCIM Provisioning” guide requires:
-
issis pinned to your full tenant issuer,https://login.microsoftonline.com/<tenant>/v2.0, and the assertion verifies against that tenant’s key set. -
audis pinned toapi://<workload-identity-app-id>, with one workload-identity application per FerroEHR deployment. -
azpis pinned to the application id of Microsoft’s provisioning service. -
utiis cached for the lifetime of the assertion, and an assertion whoseutiwas seen before is refused as a replay. - The access token it issues holds the grant’s
token_scope, names the client inclient_id, and lives between 1 and 6 hours, the range Microsoft’s guide asks for.
The assertion’s
subis the object id of a Microsoft application that every integration in the tenant shares, never yourclient_id, so it does not meet RFC 7523 §3 item 2.B. Accepting it is a deviation of your authorization server; record it there. Leaving Entra’s Secret Token blank, so that Entra uses its own token, is not supported: Microsoft reserves it for testing, and every non-gallery application in the tenant receives a token with the sameissandaud(RFC 9700 §2.3). A long-lived bearer token is not supported either. -
-
Point Entra at FerroEHR. Set the Tenant URL to
<server.public_base_url>/scim/v2and run Test Connection. Entra queries/Userswithfilter=externalId eq "<random guid>", which FerroEHR answers with an emptyListResponse, and fetches a random User and a random Group, each answered 404. -
Map the attributes in Entra. Map
userName,externalId,activeand the attributes of step 1. Map the attribute that carries the professional’s login identifier tourn:ietf:params:scim:schemas:extension:ferrohealth:2.0:User:loginIdentifier; Entra sends it without listing the extension inschemas, which FerroEHR accepts. An attribute the person template does not map is refused as undefined, so remove the rest of Entra’s default mappings. -
Protect against mass deactivation. Turn on Entra’s accidental deletions prevention, with a threshold at or below
max_deactivations. -
Provision groups. Map the group’s
objectIdto itsexternalId, so the object ids Entra puts in thegroupsclaim match, and provision only the groups assigned to the application, which keeps a person’s token under the groups overage limit. Entra creates each Group with no member, reads it withexcludedAttributes=members, finds it bydisplayName, and adds and removes members with PATCH.
Entra writes Replace and Add with a capital letter, disables a User with
active = false, sends DELETE once the user is removed, and never sends a
null. A value cleared in Entra therefore stays in FerroEHR until the User is
replaced or deleted, or an administrator removes it.