Skip to content

Architecture / Decision records / ADR-HIS-062

ADR-HIS-062 The gateways: one checked model rendered to APISIX, a gateway decision on the API operation, and the degraded path

Status Accepted
Decided 2026-11-25 by session RC-1-S12
Record Drafted 2026-11-25; approved 2026-11-30 by the Enterprise Architecture Board
Where the rule lives platform/gateways/ (its README.md; the model in model/, the plugin in apisix/lua/, the renderer bin/gateways, the rendered configuration in rendered/<env>/)

Context

RC-1-S12 builds MOD-ISE-002, the API, web and partner gateways, for FR-ISE-GWY-001, with the test scenarios TEST-ISE-007 and TEST-ISE-039. Technology stack row 8 selects Apache APISIX (ADR-HIS-008). The contract points of contracts/ise ask the gateway to apply IF-ISE-001 at ingress and to map /v<major>/ paths to the units. The card and the specification leave these choices open:

  • how routes, limits and client registrations are written down, reviewed and audited (part 3: "route must reference a catalogue entry"; part 12: route and limit changes "with before/after values");
  • how the contract paths of different units are kept apart: /v1/services is an ESS and an ISE path, and /v1/identifier-resolutions an ADM and an ESS one;
  • what the gateway asks the D10 policy decision point, since it knows the operation and caller but often not the patient or the record;
  • how a revoked credential is caught before the token expires (AC-02);
  • how the degraded path of D02-ISE 9.1 knows which reads are Tier 1 clinical reads and which content is restricted;
  • how audit events leave a gateway that has no database (part 13).

Decision

  1. One checked model, rendered. The gateways are configured from TOML under platform/gateways/model/:
  2. gateway.toml: settings;
  3. clients.toml: client registrations, Active, Suspended or Revoked;
  4. apis.toml: the published APIs;
  5. environments/<env>.toml: addresses.

bin/gateways check refuses any of these: - a value that differs from CFG-ISE-001, CFG-ISE-031 or CFG-ESS-025; - a route without a published contract; - a duplicate route; - a deprecation shorter than CFG-ISE-002.

bin/gateways render writes the APISIX configuration in standalone (declarative, no etcd) mode, the Kubernetes manifests and the Argo CD application to rendered/<env>/. The routes are derived from each contract's generated stub (contracts/<domain>/stubs/stub.json), so there is no hand-written route. bin/gateways changes turns a merged model change into ise.config.changed audit events with before and after values.

  1. One plugin. A single APISIX plugin, his-gateway (Lua, in apisix/lua/), runs the whole chain in a fixed order in the rewrite phase:
  2. correlation identifier;
  3. TLS;
  4. version lifecycle;
  5. load shedding by tier;
  6. authentication;
  7. rate limits;
  8. contract validation;
  9. policy decision;
  10. the audit path;
  11. forwarding.

It answers every error as the Problem of IF-ISE-001. The rewrite phase is used so that the published path is the one checked and logged, before proxy-rewrite changes it. Plain HTTP is bound to the loopback interface only. Upstream errors are replaced by a Problem. A per-unit circuit breaker fails fast while a unit keeps failing. APISIX's api-breaker counts per host and URI, not per unit, so it is not used. The unit breaker uses the rule of CFG-ISE-031, because the specification sets none for units.

  1. Paths are /<domain>/v<major>/<contract path>. The gateway forwards to the unit that serves the API at the contract's own path (/adm/v1/registrations → adm-patient-administration /v1/registrations). The domain prefix keeps domains apart without changing any contract. A retired major answers 404 not-found with successorVersion and a Link: rel="successor-version", since IF-ISE-001 has no error class of its own for it. A deprecated major carries Deprecation (RFC 9745) and Sunset (RFC 8594). Service-to-service APIs are not published at any gateway:
  2. the policy decision API;
  3. audit intake;
  4. identity source events.

  5. The gateway decides on the operation. The gateway asks decide with:

  6. the resource type ise.ApiOperation, id <domain>.<api>.<operationId>;
  7. the operation's action code (view, query, create, update, delete, export);
  8. the subject of the token;
  9. the purpose of use and facility headers;
  10. the patient where a path parameter carries one (patientRef);
  11. the client, its class, the channel and the tier as attributes.

It does not ask on the unit's own resource type, because it rarely knows the record's attributes, and an incomplete request would be denied. The unit still asks again at its own boundary (FR-ISE-GWY-001 behaviour 3, architecture 8.1). D10 must register ise.ApiOperation and its policy.

Obligations: - step-up is answered 401 with insufficient_user_authentication; - on the internal gateway, other obligations are left to the unit, which receives them from its own decision; - the partner gateway applies only elevated-audit and session-marker, and refuses any other obligation (redaction comes with FR-ISE-GWY-003).

  1. Credentials.
  2. The signature is checked against the realm's keys, with the issuer, lifetime and 30 seconds of leeway.
  3. The token must name the gateway's client (ise-gateways) in its audience.
  4. The azp must be a client registered at that gateway and Active.
  5. The token must still be active by RFC 7662 introspection, with the answer kept for at most 10 seconds. Keycloak introspects a token only for a client in its audience, so the audience rule is also what makes introspection possible.
  6. When introspection cannot be reached, a token that passes the local checks is accepted: existing sessions run to expiry during an identity provider outage (architecture 8.2).

Rate limits are counted per session for user channels, per client for partners and services, and per grant for patient-authorized applications, each per route (CFG-ISE-001).

  1. The degraded path is declared per operation. While the decision service is unavailable (timeout, error, unreadable answer or open circuit), the request is Deny except where D02-ISE 9.1 allows otherwise:
  2. External gateway (and any external patient-data route): fails closed with no data.
  3. Break-the-Glass: operations listed in apis.toml under emergency_access are forwarded, since the D10 emergency access service decides on local policy data.
  4. Internal Tier 1 clinical reads: operations listed under degraded_read may use the last Permit stored for the same user, client application and its class, channel, operation, patient, facility and purpose, no older than CFG-ESS-025. They never do for an operation listed under restricted, nor for a Permit that carried an obligation. Each use is audited as ise.gateway.cached-permit-used.
  5. Everything else: refused with "Authorization service unavailable", a retry indication, and "the action was not saved" for writes.

While the decision service answers, every request is decided afresh and no Permit is reused, whatever its cacheLifetimeSeconds. IF-ESS-003 (PR-AUZ-001-5) drops a cached decision on PolicyUpdated, IdentityChanged and ConsentChanged, and the gateway does not consume those events. The stored Permit is the last decision for its key: a later Permit replaces it, and a Deny or a refused request deletes it. Even so, a Permit stored before one of those events and not asked again since could be used on the degraded path within CFG-ESS-025. So bin/gateways check refuses degraded_read in every environment but the test bed until the gateway drops stored Permits on those events (question Q5 on issue #26). After CFG-ISE-031's 15 minutes the message names the downtime procedure, and the metric apisix_his_gateway_policy_outage_seconds drives the downtime alert (observability/alert-rules.yaml).

  1. Audit without a database. Events are queued per worker in memory and sent in batches to submitAuditEventBatch, with the gateway's own service token. They are retried until acknowledged. While delivery fails, the audit path is marked unconfirmed, and external patient-data routes fail closed (BR-ESS-022). The gateway emits these events:
Event type When
ise.api.client-access Every external access to patient data
ise.gateway.denied Every denial
ise.gateway.cached-permit-used Every use of a cached Permit

Internal access is audited by the unit, which knows the record. Every transaction is in the JSON access log with correlation, trace and span identifiers, and in the APISIX metrics.

Consequences

  • A route, limit or client change is a pull request on the model, checked, rendered and audited. The rendered files are checked to be current by ci.sh.
  • A new API version appears at the gateway when its contract's stub has it and apis.toml gives it a lifecycle entry.
  • A gateway replica's audit queue is lost if the replica dies before delivery. The window is at most a few seconds, because the queue is flushed every second. A durable spool is a follow-up should the audit reconciliation (FR-ESS-AUD-001) show losses.
  • D10 work this creates:
  • register the policy resource type ise.ApiOperation and its policy (RC-1-S16, RC-1-S17);
  • register the audit event type ise.gateway.cached-permit-used (RC-1-S04's catalogue);
  • add an audience mapper naming ise-gateways to every client that calls the HIS through a gateway (the identity service and the development realm);
  • create the service identity ise-gateways with introspection, decision and audit-intake rights.
  • The service kit's own Tier 1 cached-decision rule is the unit's concern. A cached Permit at the gateway lets the read through only to a unit that can still decide.
  • Which operations are Tier 1 clinical reads or restricted is declared by the session that publishes the API, once the gateway consumes PolicyUpdated, IdentityChanged and ConsentChanged (the model check refuses it before then). No RC-1 operation is declared either way until its owner says so (the question on issue #26).