Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Configuration

FerroSMART reads one configuration tree, in this order, the later winning:

  1. the TOML file --config names, or FERROSMART_CONFIG does;
  2. the environment, every key as FERROSMART__<SECTION>__<KEY>, with an index for an element of an array of tables (FERROSMART__FERROSMART__RESOURCE__0__BASE);
  3. --set key=value pairs on the command line.

Every table refuses a key it does not know, so a typing error fails the start instead of being ignored. Every secret has a _file form that names a file holding it, such as url_file beside url; use the file form, so a secret stays out of the environment. ferrosmart config check prints the tree as FerroSMART reads it, every secret masked, and exits non-zero naming the first key it cannot run with.

A duration is written as "5min", "8h" or "30d".

[server]

The listener and the request stack every FerroHEALTH server shares.

KeyDefaultWhat it is
listen127.0.0.1:8080 (the image sets 0.0.0.0:8080)The address the listener binds
base_pathemptyThe path every route is served under; it must equal the issuer’s path
request_timeout30sHow long one request may take before a 408
header_read_timeout30sHow long a client may take to send its request head
idle_timeout2minHow long an idle connection is kept
body_limit1 MiBThe largest request body read before a 413
drain_delay0sHow long readiness stays withdrawn before the listener closes
shutdown_timeout10sHow long requests in flight may take once the listener closed
max_concurrent_requests256Requests served at once before a 503 with Retry-After
trusted_proxiesnoneThe reverse proxies whose forwarded client address is believed
caller_ratenoneA request rate per caller, refused past it
compressiontrueWhether responses are compressed for a client that accepts it
[server.tls]noneTLS on the listener: certificate_file, key_file, min_version, and client certificates; unset, the listener speaks plain HTTP behind a proxy that terminates TLS

The table is the ferrohealth-server crate’s, documented on docs.rs.

[telemetry]

The console log. format is auto (readable on a terminal, JSON otherwise), pretty or json; filter is a RUST_LOG filter such as info, and RUST_LOG sets it too. No line carries a token, a code, a secret or an assertion.

[ferrosmart]

KeyDefaultWhat it is
issuerrequiredThe issuer identifier (RFC 8414 §2): an https URL with no query or fragment, or http on a loopback host. Its path is [server] base_path. Every document repeats it exactly
access_token_lifetime5minHow long an access token lives, for every grant; at most one hour (SMART App Launch 2.2.0, App Launch)
refresh_idle30dHow long an offline_access refresh token lasts unused; each refresh starts it again
online_idle8hHow long an online_access refresh token lasts unused, and never past the person’s login at the identity provider

None of the three lifetimes may be zero.

[ferrosmart.database]

KeyDefaultWhat it is
url_fileA file holding the PostgreSQL connection URL
urlThe URL itself; set one of the two
max_connections16The most connections one replica holds

Every piece of state is in the database, so any number of replicas share one. Migrations ship in the binary and run at start.

[ferrosmart.keys]

The RSA keys that sign every access token and ID Token under RS256 (keys and rotation).

KeyDefaultWhat it is
private_key_filerequiredThe PEM file of the key that signs
kidits RFC 7638 thumbprintThe kid the key is published under
next_private_key_filenoneThe key a rotation makes current, published ahead and never signing
previous_private_key_filenoneThe key that signed before a rotation, published and never signing
previous_key_overlap0sHow long the previous key stays published; "0s" for as long as it is configured

[[ferrosmart.resource]]

Each FHIR or openEHR server a token may be for. Its base URL is the aud of the tokens issued for it. At least one is required, and no base twice.

KeyWhat it is
baseThe server’s base URL as its clients name it: https, or http on a loopback host, no query or fragment
kindfhir or openehr
subject_namespaceopenEHR only: the namespace the server’s EHRs name their subjects in, which the patient picker looks an EHR up by. Unset, the picker is not offered at that base
fhir_baseopenEHR only: the base of the same platform’s FHIR server, one of the FHIR bases configured here. The patient picker then searches that server for the patient and looks their EHR up, so the app gets both patient and ehrId. Needs subject_namespace and subject_system
subject_systemWith fhir_base: the system of the Patient.identifier whose value is the subject id of the patient’s EHR in subject_namespace
fhir_user_lookupFHIR only, a list of tables: how to find a person’s fhirUser when the identity provider sends none (below)
purposeopenEHR only, a list of tables: the purposes of use the server accepts, one of which a professional chooses on the patient picker (below). Empty, a lookup declares none
purpose_headeropenEHR only, with purpose: the header a picker lookup declares the purpose in. Default x-purpose-of-use, FerroEHR’s default [audit] purpose_header

When the identity provider sends no fhirUser claim, FerroSMART can find the person at a FHIR server by an identifier. Each [[ferrosmart.resource.fhir_user_lookup]] names a resource_type (Practitioner, PractitionerRole, Patient, RelatedPerson or Person), the upstream ID Token claim whose text is the identifier’s value, and the identifier’s system. FerroSMART searches [base]/[resource_type]?identifier=[system]|[value] as the person. One match across the tables is the person’s fhirUser; none, several or a refused search leave it out, and the consent page tells the person their account is linked to no single record. A lookup on the FHIR base paired with an openEHR base also serves requests to that openEHR base.

[[ferrosmart.resource]]
base = "https://ehr.example.org/fhir"

[[ferrosmart.resource.fhir_user_lookup]]
resource_type = "Practitioner"
claim = "staff_id"
system = "urn:example:staff"

An openEHR server such as FerroEHR decides a professional’s request by their roles and by the purpose of use the request declares in a header. The patient picker’s token carries the person’s roles, and each [[ferrosmart.resource.purpose]] names a purpose the server accepts: the code sent as the header’s value (visible ASCII, no comma, one of the server’s accepted codes, FerroEHR’s [audit] purpose_codes), its code system (an absolute URI) and the display the picker page shows. The professional chooses one on the picker page (it is preselected when only one is listed), and the EHR lookup and the look-up-again of the choice both send it. The choice is kept for the rest of the request, so the two always declare the same purpose. A patient looking up their own record declares none. FerroSMART’s access record of each lookup names the purpose.

[[ferrosmart.resource]]
base = "https://ehr.example.org/openehr/v1"
kind = "openehr"
subject_namespace = "examples"
purpose_header = "x-purpose-of-use"

[[ferrosmart.resource.purpose]]
code = "TREAT"
system = "http://terminology.hl7.org/CodeSystem/v3-ActReason"
display = "Treatment"

[[ferrosmart.resource.purpose]]
code = "ETREAT"
system = "http://terminology.hl7.org/CodeSystem/v3-ActReason"
display = "Emergency treatment"

[[ferrosmart.upstream]]

The identity providers people log in at (identity providers), one entry each. Without an entry, nobody logs in and FerroSMART answers Backend Services alone.

KeyWhat it is
nameThe provider’s name, of letters, digits and -, unique among the entries; a client’s upstreams names it
labelThe words the chooser page shows for the provider; its name when empty
presetkeycloak, entra, okta or zitadel: the defaults of FerroSMART’s tested setup with that provider, for an OpenID Connect entry; none by default

The table present names the protocol: [ferrosmart.upstream.oidc] for OpenID Connect or [ferrosmart.upstream.saml] for SAML 2.0, exactly one per entry.

Each entry has its own issuer, and two entries never share one. A client lists the providers its people may log in at in upstreams; with none listed it may use every provider. With one provider the browser goes straight to it; with several, FerroSMART shows a chooser at {issuer}/login. Several Microsoft Entra ID tenants are several entries, one per tenant authority.

[ferrosmart.upstream.oidc]. A key the table leaves out takes the preset’s value, then the default below; a key the table sets wins over the preset.

KeyWhat it is
issuerThe provider’s issuer, whose discovery document FerroSMART reads at start
client_idThe client FerroSMART is registered as at the provider
scopesThe scopes FerroSMART asks for, openid among them; ["openid"] by default
fhir_user_claimThe ID Token claim holding the person’s fhirUser; empty for none, the default
role_claimsThe ID Token claims holding the person’s roles, each a dotted path; a claim name with a dot is read whole first. roles, groups and entitlements by default
trusted_audiencesAudiences an ID Token may carry beside the client id, such as a project the provider adds; empty trusts none, the default
Presetscopesfhir_user_claimrole_claimsalgorithm
keycloakopenidfhir_userrolesRS256
entraopenid profileextn.fhirUserrolesPS256
oktaopenid profilefhir_usergroupsRS256
zitadelopenid profilefhirUserurn:zitadel:iam:org:project:rolesRS256

Each preset is a data file under app/ferrosmart/presets/ with the provider’s documentation cited beside each value (identity providers).

FerroSMART authenticates at the provider with private_key_jwt unless the entry names [ferrosmart.upstream.oidc.client_secret_basic]; the assertion keys go in [ferrosmart.upstream.oidc.private_key_jwt.keys], and the private_key_jwt table itself is needed only for a key below. An entry never names both, and FerroSMART refuses a provider whose discovery document does not list the method.

Key of client_secret_basicWhat it is
secret_fileThe file holding the client secret the provider issued, sent as HTTP Basic (RFC 6749 §2.3.1); secret sets it inline

The private_key_jwt table:

KeyWhat it is
algorithmThe JWS algorithm the provider’s registration names; the preset’s, else RS256
certificate_fileThe X.509 certificate of the current assertion key, for a provider that knows the key by its certificate; each assertion then names it by x5t#S256
[ferrosmart.upstream.oidc.private_key_jwt.keys]The assertion ring, with the same keys as [ferrosmart.keys]; it may share no key with the token ring. Its kid is the id the provider knows the key by, such as ZITADEL’s key id

[ferrosmart.upstream.saml], for a SAML 2.0 identity provider (SAML 2.0 providers):

KeyWhat it is
entity_idThe identity provider’s entity ID, an absolute URI
metadata_urlThe https URL its metadata is read from; exclusive with metadata_file
metadata_fileThe file its metadata is read from
metadata_signing_certificate_filesThe PEM certificates whose keys must sign the metadata; empty trusts it as read
metadata_refreshHow often the metadata is read again; 24h by default. A failed read keeps the last good copy until its validUntil
request_bindingredirect (the default) or post: how the browser carries the signed AuthnRequest
response_bindingpost (the default) or artifact: how the provider answers. An artifact is resolved over mutual TLS with the identity of [ferrosmart.saml.tls]
force_authnWhether every request asks the provider to authenticate the person afresh; prompt=login and max_age ask it per request
name_id_formatThe name identifier format asked for; empty asks for none
authn_contextsThe authentication context classes at or above the provider’s minimum assurance, in its own vocabulary. FerroSMART asks for them as an exact match and refuses a login of any other class; empty accepts any
clock_skewThe clock skew admitted at each time bound; 3min by default, at most one hour
subject_attributeThe attribute whose one value is the person’s identifier; empty takes the NameID, which must not be transient
claimsA table of claim name to attribute Name: the claims the login yields, a string for one value and an array for more. name, preferred_username and email are read as the ID Token claims of those names are
fhir_user_claimThe claim of claims holding the person’s fhirUser; empty for none
role_claimsThe claims of claims holding the person’s roles

[ferrosmart.saml]

FerroSMART as one SAML 2.0 service provider, which every protocol = "saml" entry needs. FerroSMART serves its metadata at {issuer}/saml/metadata and takes the provider’s answer at {issuer}/saml/acs.

KeyWhat it is
entity_idFerroSMART’s entity ID; {issuer}/saml/metadata by default
signing_key_fileThe PKCS#8 PEM key that signs every AuthnRequest and ArtifactResolve: RSA of 2048 bits or more, or ECDSA on P-256 or P-384
signing_certificate_fileThe PEM certificate of that key, which the metadata publishes
[[ferrosmart.saml.decryption]]key_file and certificate_file of an RSA key a provider encrypts assertions, identifiers and attributes for
[ferrosmart.saml.tls]client_identity_file, the certificate and key artifact resolution presents, and trust_roots_file, roots beside the platform’s for every call to a provider

[[ferrosmart.role]] and [[ferrosmart.client]]

The policy: what each role may be granted and which clients exist. Clients, roles and consent describes both tables.

[ferrosmart.branding]

The deployment’s own words on the pages. Content, never code.

KeyWhat it is
nameThe name the pages carry, such as the hospital’s
consent_textThe deployment’s words on the consent page, such as what it does with the access a person gives
smart_style_urlThe smart_style_url every token response carries: an https URL of the deployment’s SMART style document; empty for none

[ferrosmart.brand]

The deployment’s User Access Brands Bundle (SMART App Launch 2.2.0, User Access Brands and Endpoints): the cards an app shows so a person can find the hospital and connect to it. With this table FerroSMART serves the Bundle at GET {issuer}/brands as application/fhir+json, readable from any origin, with a weak ETag that a request’s If-None-Match answers with 304. Without it the route is absent.

The table is the primary brand. Every FHIR server it publishes is a [[ferrosmart.brand.endpoint]], which the primary brand references.

KeyWhat it is
nameThe name people recognize the brand by. Required
websiteThe brand’s own https website, apart from any portal. Required
identifierThe identifiers apps merge brands by, each { system, value }; SMART recommends system = "urn:ietf:rfc:3986" with the website’s origin, without www., as value. An identifier belongs to one brand
aliasOther names people may search by, such as a former name
categoryCodes of SMART’s user-access-category: prov, ins, laboratory, imaging, pharmacy, health-information-network, health-data-aggregator
logo, logo_licenseThe brand’s logo, an https or data URL, and the https page of its terms of use
addressThe places of the brand, each { line, city, state, postal_code, country }
[[ferrosmart.brand.portal]]A portal people manage their account in: name, description (Markdown), url, logo, logo_license, and endpoints, the bases of the endpoints it offers
[[ferrosmart.brand.endpoint]]A FHIR server of the Bundle: base, one of the FHIR [[ferrosmart.resource]] bases; name; fhir_version, such as ["4.0.1"], at least one; and contact, at least one https page where developers configure access
[[ferrosmart.brand.affiliate]]An affiliated brand, part of the primary one, with the same keys but endpoint and affiliate, and portals of its own

Bundle.timestamp is the moment the contents last changed, and each resource’s meta.lastUpdated the moment that brand or endpoint last changed: FerroSMART keeps a digest of the contents and of each resource in its database, so a restart with the same table keeps every moment and every replica serves the same Bundle. Each FHIR server names the Bundle in its own .well-known/smart-configuration as user_access_brand_bundle, with one of the brand’s identifiers as user_access_brand_identifier when the Bundle holds more than one brand.

[ferrosmart.brand]
name = "Example Hospital"
website = "https://example.org"
identifier = [{ system = "urn:ietf:rfc:3986", value = "https://example.org" }]
category = ["prov"]
logo = "https://example.org/logo.svg"

[[ferrosmart.brand.portal]]
name = "Patient Portal"
url = "https://portal.example.org"
endpoints = ["https://ehr.example.org/fhir"]

[[ferrosmart.brand.endpoint]]
base = "https://ehr.example.org/fhir"
fhir_version = ["4.0.1"]
contact = ["https://developer.example.org"]

[ferrosmart.audit]

How FerroSMART names itself in its audit records, and where it forwards them.

KeyWhat it is
source_idFerroSMART as the recording system, AuditEvent.source.observer; empty takes the issuer’s host
siteThe site FerroSMART runs at, AuditEvent.source.site
[ferrosmart.audit.feed]An Audit Record Repository: url, an https FHIR base the records are created under as [base]/AuditEvent, with timeout, connect_timeout, retry, tls and credentials (Basic, or an OAuth 2.0 client credentials grant under credentials.oauth). Unset, the records stay in FerroSMART’s own store

A whole file

[ferrosmart]
issuer = "https://smart.example.org"

[ferrosmart.database]
url_file = "/run/secrets/ferrosmart-db-url"

[ferrosmart.keys]
private_key_file = "/run/secrets/rs256.pem"

[[ferrosmart.resource]]
base = "https://ehr.example.org/fhir"
kind = "fhir"

[[ferrosmart.upstream]]
name = "idp"
preset = "keycloak"

[ferrosmart.upstream.oidc]
issuer = "https://idp.example.org/realms/hospital"
client_id = "ferrosmart"

[ferrosmart.upstream.oidc.private_key_jwt.keys]
private_key_file = "/run/secrets/upstream-assertion.pem"

[[ferrosmart.role]]
name = "clinician"
scopes = ["user/Patient.rs", "user/Observation.rs"]

[[ferrosmart.client]]
client_id = "growth-chart"
name = "Growth chart"
kind = "public"
resources = ["https://ehr.example.org/fhir"]
redirect_uris = ["https://growth-chart.example.org/callback"]
scopes = ["openid", "fhirUser", "launch", "launch/patient", "patient/Observation.rs"]
grant_types = ["authorization_code"]

[ferrosmart.branding]
name = "Example Hospital"

[ferrosmart.audit]
site = "Example Hospital"