Internal API implementation
Scope and authority
The ion-internal-api realization is an APIM-only, policy-driven gateway. The repository contains no application or backend implementation for this service: ion-internal-api/app/ contains only a readme and CodeQL configuration. Terraform imports an OpenAPI bundle into the shared ION API Management instance and attaches API-level and operation-level XML policies. Three data operations proxy to the separately implemented Doppio Function App; liveness is synthesized in APIM.
This page documents the checked-in implementation. All four operations are present in the source contract, generated bundle, Terraform map, and operation policy files. This review did not query or exercise live Azure resources, so it does not assert that any environment is currently deployed, healthy, or reachable.
Use these authorities in order:
api/specs/openapi-index.yamlis the editable source contract.api/specs/openapi.yamlis the generated, bundled artifact imported by Terraform; do not edit it by hand.- APIM global, API-level, and operation policies are the authority for runtime enforcement. Where OpenAPI or prose differs from policy/Terraform, the runtime policies described below win.
Current realization
The external request path is exactly:
Client
-> Azure Front Door
-> Azure Application Gateway
-> Azure API Management API path intapi-ext
-> Doppio Function App
Front Door’s ion-internal-api-v1 route selects the shared RomeApiOriginGroup and its rome-appgateway-primary origin. Application Gateway’s gateway-pool targets the environment APIM endpoint over HTTPS. APIM exposes the imported API at intapi-ext. For the three data operations, an operation policy selects the Doppio Function App backend and rewrites the public path. The liveness operation stops inside APIM and therefore does not traverse the final Doppio hop.
The Application Gateway hop is material. Diagrams that show Front Door going directly to APIM omit the configured primary request path.
Environments and naming
| Environment | Code | Client hostname | Internal API app audience client ID |
|---|---|---|---|
| Alpha | apa | api.internal.alpha-ion.dev | 45aacb32-7844-4894-9986-d5e78886a8da |
| Beta | bta | api.internal.beta-ion.dev | 470448ab-4f56-46f3-86d5-1d08f62a6048 |
| Gamma | gma | api.internal.gamma-ion.dev | 533c71b6-179d-4dd7-bdf5-20c1ef540e25 |
| Prod | prd | api.internal.ion.ontinue.com | 97f30357-df31-4707-b642-642983da854b |
The corresponding Entra application is azsp-ontinue-rome-idm-ion-internal-api-{env}-01. A consumer requests a token for that environment’s application audience.
Checked-in resource conventions are:
| Resource | Pattern |
|---|---|
| Resource group | rg-rome-{env}-chn-01 |
| Shared APIM service | apim-rome-{env}-chn-02 |
| APIM API resource | apim-api-ion-int-api-internal-{env}-chn-02 |
| APIM product | apim-product-ion-int-api-internal-{env}-chn-01 |
| APIM API path | intapi-ext |
| Internal API APIM UAMI | id-apim-{env}-chn-inapi |
| Doppio Function App | func-dprso-{env}-chn-02 |
| Doppio backend base URL | https://func-dprso-{env}-chn-02.azurewebsites.net/api |
In these patterns, {env} is apa, bta, gma, or prd as supplied by the environment tfvars.
Operations
| Method and public path | operationId | Runtime role requirement | Doppio rewrite |
|---|---|---|---|
HEAD /v1/healthcheck/liveness | head_healthcheck_liveness | Ion.Health.Read | None; APIM returns 200 synthetically |
GET /v1/customers | get_customers_configuration | Ion.Internal.Customers.Read.All | /v1/base-config/customers |
GET /v1/customers/{customer-short} | get_customer_configuration | Either Ion.Internal.Customers.Read or Ion.Internal.Customers.Read.All | /v1/base-config/customers/{customer-short} |
GET /v1/customers/{customer-short}/ConsentValidation | get_consent_validation_status | Either Ion.Internal.Customers.Read or Ion.Internal.Customers.Read.All | /v1/customers/{customer-short}/consent-validation-status |
The public consent path intentionally retains the checked-in ConsentValidation casing. Runtime role requirements in this table come from Terraform’s roles_csv, not from the OpenAPI security declaration.
Three-way operation invariant
Every operation must maintain this exact identity relationship:
openapi-index.yaml operationId
== api/policies/apim-api-operation-<operationId>.xml filename stem
== apim.tf apim_api_operations_policy map key
The Terraform module uses the map key as the APIM operation ID. A mismatch can prevent the policy from attaching to the imported operation. Changes therefore require editing the source contract, regenerating openapi.yaml, adding or changing the matching policy file, and wiring the same operationId in Terraform.
Policy layers
APIM composes three layers because each child policy begins with <base />.
Global APIM policy
The environment-specific shared APIM global policy:
- requires an
Authorizationheader; - creates
X-Transaction-Idif the request did not supply one; - extracts and validates
tid, performs tenant validation for non-Ontinue tenants, and requiresrolesandtidclaims; - validates JWT signature, issuer, and an environment-specific list of accepted audiences;
- overrides
X-Tenant-Idfrom the validatedtidclaim; - sets
AuthorizationandX-Authorizationonly if absent at this layer; - overrides
Forwardedwithproto, original host, and original path; - traces requests and responses;
- limits backend concurrency per
context.Api.Idto30in alpha and beta, and200in gamma and prod; and - forwards with a
120second timeout andfail-on-error-status-code="true".
The global audience list is shared across APIs. It includes the environment’s Internal API application client ID, but also accepts several other ION application audiences. It does not exclusively bind intapi-ext to the Internal API audience.
Internal API-level policy
apim-ion-internal-api-policy.xml applies to every operation. It creates a counter key from context.Api.Id plus the validated JWT oid, then allows 50 counted calls per 60 seconds. The increment condition counts only responses with status 200 through 399; failed responses do not consume the counter. The policy emits X-RateLimit-IonInternalApi-Remaining-User and removes x-aspnet-version and x-powered-by from responses.
The effective key is therefore API + caller oid, not operation, tenant, or subscription.
Operation policies
Each operation policy checks whether the JWT roles array contains any role supplied through Terraform’s roles_csv. A missing or unmatched role returns a bare 403 Forbidden after populating tracing variables; the policy does not set the documented JSON error body.
For the three Doppio operations, the policy then:
- selects the Doppio backend base URL;
- rewrites to the Terraform-provided Doppio path while copying unmatched query parameters;
- obtains a platform token with
authentication-managed-identity, using resource named valueAPIM-AZURE-AD-APPLICATION-IDand client ID named valueAPIM-INAPI-MSI-CLIENT-ID; and - overrides both
AuthorizationandX-Authorizationwith that managed-identity bearer token.
APIM-INAPI-MSI-CLIENT-ID resolves through Key Vault to the UAMI id-apim-{env}-chn-inapi. Consequently, Doppio receives the platform token minted for this APIM identity, not the original caller token, in both authorization headers. The globally derived X-Tenant-Id, X-Transaction-Id, and Forwarded headers remain available to the backend.
The liveness policy performs the same operation role check but returns 200 OK directly in its success branch. It does not configure, rewrite to, or call Doppio. It proves APIM policy execution and authorization only; it is not a Doppio dependency check.
Front Door and Application Gateway
The checked-in Front Door service route has these effective settings:
| Concern | Realization |
|---|---|
| Match | /v1/* on the api.internal endpoint |
| Primary origin | rome-appgateway-primary in RomeApiOriginGroup |
| Origin path | /intapi-ext/v1/ |
| Client protocols | HTTP and HTTPS accepted by the route |
| HTTPS | Redirect enabled by the shared module; origin forwarding is HttpsOnly |
| Cache | Disabled; no cache block is emitted |
| Compression | Disabled with no compressed content types; also moot while cache is disabled |
| WAF | Service WAF enabled in Prevention mode for /*; Microsoft Default Rule Set 2.1 and Bot Manager 1.0 block |
| CORS | Front Door CORS rule attached; configured origins are the environment’s portal and portal.alya hostnames, and a matching response overwrites Access-Control-Allow-Origin |
Application Gateway listens over HTTPS and sends the default API route to the gateway-pool, whose FQDN is the environment APIM endpoint. Its APIM backend settings use HTTPS on port 443 and APIM host-name override.
The service route sets preserve_unmatched_path = true, but the checked-in azure-front-door-service module never reads that route property. Path preservation is governed by Azure Front Door’s route/origin-path behavior, not this unused input. Treat the field as dead configuration until the module consumes it or the declaration is removed.
Deployment and availability
The Internal API and its Front Door route are separate Terraform states and separate workflow rollouts.
ion-internal-api-pr.ymlplans and applies the APIM API and policies to alpha on a pull request.- After merge,
ion-internal-api.ymlplans/applies beta, then gamma, then prod frommain, with dependency ordering between environments. - Front Door service changes under
rome-ion/infrastructure/hub/azure-front-door/services/ion-internal-api/use the separate AFD service workflows: alpha on the PR workflow, then beta, gamma, and prod from themainworkflow.
All four operations are checked in. The workflows are infrastructure-oriented and provide no operation-level Internal API smoke suite that verifies authentication, role denial, rewrites, Doppio payloads, headers, or rate limiting. Generic AFD tests after non-alpha rollout do not replace those API behavior checks. No live Azure validation was performed for this document.
Current constraints and discrepancies
| Area | Verified implementation | Discrepancy or consequence |
|---|---|---|
| Consent roles | Terraform enforces Ion.Internal.Customers.Read or .Read.All. | OpenAPI and the consumer reference advertise Ion.Platform.CustomerConfigurationData.Read or .ReadWrite. A token following the contract can receive 403; runtime Terraform/policy is authoritative. |
| Audience isolation | Shared global APIM JWT policy accepts the Internal API client ID plus multiple ION app audiences. | The runtime is not exclusively restricted to the documented Internal API app audience. Operation roles provide the next authorization boundary. |
| Topology | Front Door targets Application Gateway, which targets APIM. | Existing consumer/reference topology that says Front Door directly reaches APIM omits Application Gateway. |
| Forbidden body | Operation policy returns status and reason only. | The documented { "statusCode": "403", "message": ... } body and OpenAPI error content type/schema are not produced by the role-denial branch. |
| Rate-limit contract | APIM emits X-RateLimit-IonInternalApi-Remaining-User; APIM itself controls any generated 429 details. | OpenAPI declares X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, and Retry-After, but the policy does not configure those names. The declared limit also says “per hour,” while runtime is 50 successful responses per 60 seconds. |
| Pagination | GET /v1/customers has no pagination query parameters in its operation and the proxy merely copies unmatched query parameters. | Guidelines/reference claims about pagination links or support are not established by this gateway contract or policy. Any backend behavior is outside this repository and was not live-validated. |
| Not found | Shared 404 response exists but none of the four operations explicitly declares it. | Consumer/reference claims for 404 are not expressed per operation in the current OpenAPI contract. Backend passthrough may still return one, but it is not guaranteed here. |
| Liveness | APIM returns synthetic 200 after JWT and role checks. | Descriptions that say it checks the service and dependencies overstate its coverage; it never calls Doppio. |
| Error/status validation | Global outbound OpenAPI header/status validation is commented out. | APIM does not enforce response conformance to the imported OpenAPI response contract. |
| Front Door path preservation | Service configuration supplies preserve_unmatched_path = true. | The local module does not consume it, so the setting has no Terraform effect. |
| Verification depth | Terraform workflows deploy infrastructure; no Internal API test files or operation smoke steps are checked in. | Regressions in roles, audiences, path rewrites, token replacement, response shape, and headers can pass the current service-specific pipeline. |
Implementation evidence
Paths are relative to the repository root.
| Evidence | Path |
|---|---|
| Gateway-only scope and invariant | ion-internal-api/AGENTS.md |
Source OpenAPI contract and four operationId values | ion-internal-api/api/specs/openapi-index.yaml |
| Generated APIM import bundle | ion-internal-api/api/specs/openapi.yaml |
| Shared responses and rate-limit header contract | ion-internal-api/api/specs/openapi/responses.yaml, ion-internal-api/api/specs/openapi/headers.yaml |
| APIM resource names, API path, and Doppio URL | ion-internal-api/infrastructure/data.tf, ion-internal-api/infrastructure/apim.tf |
| API rate limit and response-header removal | ion-internal-api/api/policies/apim-ion-internal-api-policy.xml |
| Synthetic liveness | ion-internal-api/api/policies/apim-api-operation-head-healthcheck-liveness.xml |
| Doppio proxy, role checks, rewrite, and token replacement | ion-internal-api/api/policies/apim-api-operation-get-customers-configuration.xml, apim-api-operation-get-customer-configuration.xml, apim-api-operation-get-consent-validation-status.xml |
| Global JWT, headers, concurrency, and timeout | rome-ion/infrastructure/spoke/apim/apim_policies/apim_global_policy_{apa,bta,gma,prd}.xml |
| Internal API managed identity and named value | rome-ion/infrastructure/spoke/apim/managed_identity.tf, apim_named_values.tf, key_vault_secrets.tf |
| Front Door route | rome-ion/infrastructure/hub/azure-front-door/services/ion-internal-api/main.tf |
| Environment host/CORS inputs | rome-ion/infrastructure/hub/azure-front-door/services/ion-internal-api/environments/mgmt-{alpha,beta,gamma,prod}.tfvars |
| Effective HTTPS route, CORS, WAF, and unused route property | tf-modules/azure/azure-front-door-service/routes.tf, rules_cors.tf, waf.tf, variables.tf |
| Application Gateway to APIM | rome-ion/infrastructure/hub/application-gateway/application_gateway.tf |
| APIM deployment sequence | .github/workflows/ion-internal-api-pr.yml, .github/workflows/ion-internal-api.yml |
| Separate Front Door sequence | .github/workflows/rome-ion-hub-afd-pr-services.yml, .github/workflows/rome-ion-hub-afd-cicd-services.yml |
| Existing consumer/reference claims | ion-internal-api/README.md, ion-internal-api/API-GUIDELINES.md |