Architecture / Decision records / ADR-HIS-084
ADR-HIS-084 Application grants: a grant register beside the policy decision API, the patient's approval as a consent directive written with the grant, every request decided with the grant, and revocation without a new event¶
| Status | Accepted |
| Decided | 2026-11-27 by session RC-6-S01 |
| Record | Drafted 2026-11-27; approved 2026-11-30 by the Enterprise Architecture Board |
| Where the rule lives | contracts/ess/api/application-grants.v1.openapi.yaml (version 1.0), contracts/ess/api/policy-decision.v1.openapi.yaml (version 1.1), contracts/ess/api/consent.v1.openapi.yaml (version 1.1), contracts/ess/README.md (tokens of an application grant), contracts/ess/CONTRACT-POINTS.md |
Context¶
FR-ESS-AUZ-004 has Domain 10 issue and evaluate grants for staff-launched applications and for patient-authorized third-party applications. Each grant is limited to one patient, a set of scopes and a purpose, has an expiry, and can be revoked. Any access outside the grant is denied. The specification fixes these points:
- Domain 10 decides and records the grant, and Domain 2 enforces the token at the gateway (DEC-ESS-007, working position (a), resolved 2026-11-24);
- SMART App Launch is used on Keycloak, and patient-authorized access is in the first release, with slice RC-6 (DEC-ESS-010, DEC-PEX-007);
- a patient's grant "is recorded as a consent directive", and an active directive naming the application and scope is a precondition (part 3, part 4);
- the required interfaces are IF-ESS-003 and EVT-ESS-002; section 8.5 has no grant event;
- D07-PEX shows the consent screen and the connected applications, and keeps no grant state of its own (FR-PEX-ACC-005, PR-ACC-005-2);
- the gateway confirms with Domain 10 that the grant is current on every request, and refuses after the propagation time once it is revoked (FR-ISE-GWY-003);
- the propagation objective is p95 at most 5 seconds (NFR-ESS-003).
That leaves five questions of build open:
- Where the grant register and registrations live in the contracts.
- How the patient's approval travels from the D07-PEX consent screen to a grant and a directive.
- How an enforcement point learns that a grant is current, and how the four acceptance criteria are decided.
- How a revocation reaches the enforcement points within the objective, with no grant event in the catalogue.
- How a token is tied to its grant and kept from being transferred.
Decision¶
- The grant part of IF-ESS-003 is a contract of its own,
application-grants.v1. It holds: - the application registrations in force (
listApplications,readApplication); - the validation hook of the configuration item type
ess.application-registration(validateApplicationRegistration). Registrations are drafted, approved and activated through the configuration lifecycle, as part 11 and UI-ESS-003 say, the same way forwarding rules are (ADR-HIS-082); - authorization requests (
createAuthorizationRequest,readAuthorizationRequest,answerAuthorizationRequest); - the grant register (
issueGrantfor staff launch,listGrants,readGrant,revokeGrant).
It is a separate file because its callers (the identity provider, D07-PEX, the launching workspace, the security officer's screen) are not the enforcement points that call the decision API. Scopes are SMART App Launch 2.2 scope strings, and lifetimes are ISO 8601 durations.
2. The patient's approval is answered to an authorization request, and the directive is written with the grant.
- The identity provider opens a pending request when an application asks a patient for access.
- D07-PEX reads it, shows the consent screen and answers approve or decline for the authenticated patient or representative.
- On approval, Domain 10 records the consent directive in the same transaction and issues the grant on it. The directive has consent type external-sharing, the application as recipient and the granted scopes in the new scope.applicationScopes of consent.v1 1.1.
- Withdrawing, expiring or marking the directive entered in error revokes the grant (PR-AUZ-004-2).
- The patient's or representative's own revocation of the grant, through D07-PEX, is their withdrawal of the consent, and it withdraws the directive in the same transaction. Any other revocation (by the launching user, a security officer or the service) revokes the grant only and leaves the directive alone. FR-ESS-CNS-001 part 3 lets only the patient or representative through Domain 7, or a consent recording user, withdraw a directive, so the consent record never shows a withdrawal the patient did not make. revokeGrant binds requestedBy to the authenticated caller and refuses a mismatch with 403. patient and representative come only from the D07-PEX portal service identity, naming the grant's patient (and the representative grant) in actingFor. user comes only from the grant's launching user, and security-officer only from a subject the policy permits to revoke any grant. A caller therefore cannot cause a withdrawal by claiming to be the patient. The grant needs no matching directive change to be denied, because a revoked grant is denied whatever its directive says (PR-AUZ-004-3).
We rejected letting D07-PEX record the directive itself and then ask for a grant. That would be two calls with no transaction between them, so a directive could exist without a grant, or the other way round, and D07-PEX would hold half of a state that PR-ACC-005-2 gives to Domain 10.
3. Every request under a grant is a policy decision with the grant. policy-decision.v1 1.1 adds an optional grant {grantId, requiredScope} to the decision request. The gateway sends it with the token's grant_id and the SMART scope the request needs. The decision is Deny when:
- the application, patient (AC-01) or purpose is not the grant's;
- the scope is not granted;
- the grant has expired (AC-02) or is revoked (AC-03);
- for a staff launch, the launching user would be denied the same action (AC-04).
Otherwise the policy decides as usual, labels and consent included (part 6.4). One call thus answers both "is the grant current" and "what may be returned" (FR-ISE-GWY-003 parts 6.1 and 6.4). A launching user's permissions are not copied into the grant at issue. They are evaluated on every request, so a role revoked after launch is honoured at once. 4. Revocation needs no new event. A decision made under a grant is cached for at most 5 seconds, which meets NFR-ESS-003 by itself. When the patient or representative revokes a patient-authorized grant, its directive is withdrawn too, and the gateway already drops cached decisions on ConsentChanged (EVT-ESS-002, the event IF-ESS-003 cites for this requirement). A grant event would have to be added to section 8.5 and the catalogue first, which a contract session may not do. Should one be wanted later, it is a compatible addition. The service also revokes a patient's grants itself when: - the portal account link is suspended or revoked (PortalAccessChanged, PR-ACC-005-3, of which ESS is already a consumer in the catalogue). The grant lifecycle has no Suspended state (part 11), so a suspended link revokes, and a reinstated link does not bring the grant back.
The contract fixes nothing for a representative whose access ends (RepresentativeAccessChanged). The specification does not say whether the grants that representative authorized survive, and that question is with its owner (Q-RC6-1 on #127). The build session of the unit takes the answer from the issue, or stops on that point under session rule 3 if it is unanswered. Building no handler would itself decide that the grants stay. The revocation cause is an extensible enum, so an answer that revokes is a compatible addition.
5. The token carries the grant and is sender-constrained. The access token of a grant carries grant_id, the granted scope and the patient context, and expires no later than the grant. It is bound to the application's key with DPoP (RFC 9449, cnf.jkt), so a copied token cannot be used by another client (part 13). The gateway checks the proof and asks the decision service with the grant. The token itself never decides.
All of it is additive. application-grants.v1 is new, policy-decision.v1 and consent.v1 go from 1.0 to 1.1, and his-contract check passes against origin/main.
Consequences¶
- RC-6-S04 (runtime decision services) builds the register, the decision under a grant, the directive written with the grant, the revocation handlers and the identity provider's grant tokens in
services/ess-runtime-decision, to the points incontracts/ess/CONTRACT-POINTS.md. - RC-6-S02 and RC-6-S05 (gateways) send the grant with every decision request of an application token, check the DPoP proof, cache for at most
cacheLifetimeSeconds, and drop cached decisions on ConsentChanged. - RC-6-S03 (PEX contracts) gives PortalAccessChanged the patient and the new state, so that ESS can revoke what it ends. It calls the authorization request and grant operations for the consent screen and connected applications, and its scenario test walks step 6 through them.
- A gateway that reuses a decision past its cache lifetime would honour a revoked grant. The 5-second ceiling is the contract, and the provider's tests check it.
- The value of the policy maximum for a grant's lifetime is not in the specification. Each registration carries its own maximum, which the validation hook keeps within the policy maximum once the security office sets it.