UDAP Security
UDAP Security (FAST Security STU2, package
hl7.fhir.us.udap-security#2.0.0) lets an application from a trust community use the server
without anyone creating a client for it. The application holds a certificate from the community.
It registers itself with a signed software statement and signs in with a JWT carrying the
certificate chain, so the server trusts the community’s anchors rather than each client.
Configuration
Section titled “Configuration”UDAP is off by default.
[auth.udap]enabled = true# This server's chain, leaf first. The leaf carries the FHIR base URL as a URI# Subject Alternative Name, for example https://fhir.example.org/fhircertificate = "/etc/octofhir/udap/server.pem"# RSA: the metadata is signed with RS256.private_key = "/etc/octofhir/udap/server.key"# What a registration can be granted. This is the default.scopes = ["openid", "fhirUser", "offline_access", "patient/*.rs", "user/*.rs", "system/*.rs"]
[[auth.udap.communities]]uri = "urn:example:community"anchors = ["/etc/octofhir/udap/community-root.pem"]revocation_lists = ["/etc/octofhir/udap/community.crl"]If a file cannot be read, or the certificate does not name the base URL, the server logs the
reason and starts with UDAP off. While UDAP is off, /fhir/.well-known/udap and the registration
endpoint answer 404. A change to the auth configuration takes effect without a restart: UDAP and
Tiered OAuth are built again from it, switched on or off, or re-keyed.
Revocation
Section titled “Revocation”A certificate chain has to lead to a community anchor, be current and not be revoked. Revocation comes from three places:
- the
revocation_listsof the community, read at start; - the lists each certificate of the chain names in its CRL Distribution Points (http or https),
fetched before the chain is validated and kept until their
nextUpdate(a day at most); - the OCSP responder the leaf certificate names in its Authority Information Access, asked once
the chain is good. The request identifies the certificate by SHA-1 hashes of its issuer’s name
and key and its serial number (RFC 6960, RFC 5019). An answer counts when the issuer signed it,
or a responder certificate the issuer issued for OCSP signing, and when it is current; it is kept
until its
nextUpdate.
A list or responder that cannot be reached is not asked again for five minutes.
[auth.udap]fetch_revocation_lists = true # the defaultcheck_ocsp = true # the defaultrequire_revocation_status = false # the defaultWith require_revocation_status = false, a certificate whose status cannot be determined (no list
covers it, a list or responder cannot be reached, the responder does not know it) is accepted, and
the failure is logged. With true it is refused. A list past its nextUpdate fails the
certificates it covers either way: it says nothing about today.
Discovery
Section titled “Discovery”GET /fhir/.well-known/udap gives the server metadata, with signed_metadata signed by the
server’s certificate. With ?community= it answers for that community, and with 204 if it is
not one of the configured ones.
Registration
Section titled “Registration”POST /auth/udap/register:
{"software_statement": "eyJ...", "udap": "1"}The software statement is a JWT with the certificate chain in x5c. Its iss has to be a URI in
the Subject Alternative Name of the certificate, aud this endpoint, and it lives 5 minutes at
most. It asks for authorization_code or client_credentials, not both.
| Answer | When |
|---|---|
201 and client_id |
A new registration. Scopes outside the configured list are dropped |
200, same client_id |
The same iss in the same community registers again: the registration is replaced |
200, grant_types: [] |
The statement has an empty grant_types: the registration is cancelled |
400 unapproved_software_statement |
No chain to an anchor, or iss is not in the certificate |
400 invalid_software_statement |
A bad signature, audience or lifetime, or a jti already used |
400 invalid_client_metadata |
A registration value is wrong, or no requested scope is available |
Certifications in the request are not read.
Getting a token
Section titled “Getting a token”The application authenticates with a JWT signed by its certificate, with udap=1 in the request:
POST /auth/tokenContent-Type: application/x-www-form-urlencoded
grant_type=client_credentials&scope=system/Patient.rs&udap=1&client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer&client_assertion=eyJ...iss and sub are the client_id, and aud is the token endpoint. The chain has to lead to the
community of the registration and the certificate has to name the registered application, so a
renewed certificate keeps working and another member’s does not.
Client credentials requests carry the hl7-b2b extension in the JWT, with version,
organization_id and purpose_of_use. The organization and purpose go to the log. Access tokens
last 60 minutes at most.
Authorization code applications use the usual /auth/authorize with PKCE, and the same JWT at the
token endpoint, without the extension.
Tiered OAuth
Section titled “Tiered OAuth”With Tiered OAuth for User Authentication, a client app names the identity provider its user signs in at, and this server signs the user in there as an OpenID Connect client. It needs external identity providers enabled, since the sign-in goes through them:
[auth.udap.tiered_oauth]enabled = true# How this server presents itself when it registers with an identity provider.client_name = "Example FHIR server" # the host of the base URL if unsetcontacts = ["mailto:fhir-ops@example.org"]logo_uri = "https://example.org/logo.png"The metadata then lists udap in scopes_supported, and registrations may ask for it. A client
app that registered with udap sends it in the authorization request with the provider’s base URL
in idp:
GET /auth/authorize?response_type=code&client_id=…&redirect_uri=…&state=…&aud=… &scope=openid%20udap%20user/*.rs&idp=https://idp.example.org- The first time a provider is named, the server reads
{idp}/.well-known/udap. It trusts the provider when thesigned_metadatavalidates up to an anchor of one of its communities, namesidpas its issuer and in its certificate, andscopes_supportedhasopenidandudap. - It registers with the provider by UDAP Dynamic Client Registration: a software statement signed
with this server’s certificate,
issthe FHIR base URL, scopesopenid udap, its federation callback as the redirect URI. The registration is kept as anIdentityProviderof typeudap: later requests reuse it, and its claim mapping and roles can be set like any other provider’s. - The browser goes to the provider with the server’s own
stateand anonce. Back at the callback, the server checks the state, exchanges the code with a signed client assertion andudap=1, validates the ID token as OpenID Connect requires (signature from the provider’s JWKS,isstheidp,audthe server’s client id, the nonce), and finds the user byissandsub(or links or provisions one, as configured for federation). - The authorization request then continues as for a user who signed in here: consent, then the code to the app.
A provider that is not trusted, or where the server cannot get a client id, is answered with
invalid_idp at the app’s redirect URI. A refusal at the provider and a user who cannot be
matched give access_denied, an answer that cannot be verified invalid_idp, all with the app’s
state.
Not done
Section titled “Not done”- OCSP is asked about the leaf only; intermediates are checked against revocation lists.
- Intermediates come from
x5c; missing ones are not fetched through the certificate’s AIA. - The experimental
jkuworkflow.