Tenant Security & Multi-Tenant Authentication
How Cloud Health Office keeps every health plan's data and access separate, and how to configure token signing, service identity and staff sign-in when your team runs the platform.
The isolation model
Cloud Health Office is multi-tenant: one deployment can serve many tenants, and each tenant is one health plan or line of business. Isolation does not depend on network placement, a request header or the portal behaving well. It rests on one rule:
A request acts within exactly one tenant, and that tenant comes only from the tenant_id claim of a token whose signature, issuer, audience and lifetime have already been validated. There is no default tenant and no header fallback.
- No tenant claim, no access. A validated token without a tenant claim is rejected with 401.
- Headers cannot change the tenant. An
X-Tenant-IDheader is accepted only when it matches the token. A header naming a different tenant is rejected with 403TENANT_CONTEXT_CONFLICTand logged. - Data access is scoped by the same value. Every service runs the shared authentication middleware, and repositories filter reads and writes by the tenant taken from the token.
- Tokens are short-lived. User and service tokens last five minutes by default, ten at most for service tokens and one hour at most for user tokens.
Who issues tokens
One component, token-service, issues every token the platform trusts. It signs with a key it cannot export (Azure Key Vault or Google Cloud KMS in production) and publishes the public key at /.well-known/jwks.json. Services hold no signing keys, so a compromised service cannot mint tokens for a user, a tenant or another service.
| Token | Issuer | Who receives it | How the caller proves itself |
|---|---|---|---|
| User | cho-token-service | The operations portal, for a signed-in staff member | The user's Microsoft Entra ID access token |
| Service | cho-token-service-svc | A platform service acting as itself (message consumers, scheduled jobs) | The pod's Entra workload identity, or its projected Kubernetes service-account token |
| Workload | cho-workload | Argo workflows (batch adjudication, file processing) | The workflow pod's projected Kubernetes service-account token |
Each issuer is trusted for one kind of token only. A service-issuer token without the service role is rejected rather than read as a user, so a service key could never be used to forge an administrator.
External applications (member apps and provider systems on the CMS-0057-F APIs) use SMART on FHIR authorization against the plan's own FHIR endpoints. That is separate from staff and service access.
Staff access: sign-in, memberships and roles
Staff sign in with Microsoft Entra ID. The portal exchanges the user's Entra token for a Cloud Health Office token, and token-service decides everything that goes into it:
- It validates the Entra token itself: signature, issuer against the token's directory, audience, the
Cho.Tokenscope and expiry. App-only tokens are refused, so the portal's own credentials cannot produce a user token. - It finds the user's membership in the requested tenant by Entra object id and directory id. A membership must be Active, and so must the tenant.
- It takes roles from the membership and expands them to permissions. Tenant administrators cannot grant platform-wide roles.
A compromised portal therefore cannot ask for a token "for user X", choose roles, or reach a tenant the user does not belong to.
Onboarding a new tenant and its users
- The tenant. A tenant is created by signup or by a platform administrator and records the plan's Entra directory id. Sign-in is open only while the tenant is active.
- Users in the plan's own directory. An administrator adds the user with their work email. On first sign-in from the plan's registered directory, the account links to that Entra identity once and permanently.
- Guests, partners and delegated administrators. People from other directories join only by invitation: a single-use code with an expiry (seven days by default), redeemed by the invited person after they sign in. Email matching never links a guest, so another directory cannot claim an account by minting a token for the same address.
- Leaving. Disabling a user or revoking an invitation takes effect at their next token, within five minutes.
Sign-in through Cloudflare Access (demos and sandboxes)
A deployment published through a Cloudflare Tunnel can use Cloudflare Access as its only sign-in. The portal trusts the signed token Access adds to every request, so people sign in once, with whatever Access allows (Google Workspace, Microsoft or a one-time email code). token-service validates that token again and issues a platform token only when:
- the tenant is listed in
CloudflareAccess:Tenants, an explicit opt-in per tenant; - the person is an Active user of that tenant with the same email address, and their roles come from that user record.
Access decides who reaches the portal; the tenant's user list decides what they can do. Use it for demonstrations and evaluation tenants; production tenants sign in through their own identity provider.
Platform administrators
Cross-tenant administration requires two things together: an Entra token from the operator's own directory (TokenService:PlatformTenantId) and the PlatformAdmin app role. A customer directory that assigns the same role gets nothing. Leave PlatformTenantId empty to turn platform administration off.
Service-to-service access
When a service calls another service without a user (a Kafka consumer posting a remittance, a nightly job), it requests a service token for the tenant it is working in. token-service works out which service is asking from a workload identity it can verify, looks it up in a registry and issues a token naming only that service. A service cannot obtain a token naming another service, and callees can require a specific caller with [RequireServiceClient("claims-service")].
| Platform | Proof of identity | Setting |
|---|---|---|
| Azure (AKS) | Entra workload identity | ServiceTokens:IdentityProvider=Entra (default) |
| Google Cloud (GKE), EKS, on premises | Projected Kubernetes service-account token, audience cho-token-service | ServiceTokens:IdentityProvider=Kubernetes |
The Kubernetes option uses no cloud identity service, so the same configuration works on any conformant cluster. Tokens are checked against the cluster's service-account issuer, must be bound to a running pod and expire within an hour. Each namespace and service account maps to exactly one service. The same service account name in another namespace is a different identity.
How this applies in each operating model
| Model | Tenants | Signing key and identities |
|---|---|---|
| In your cloud | Your plan's tenants only | In your Key Vault or Cloud KMS, under your cloud account. You configure everything below. |
| In your cloud, operated by Aurelianware | Your plan's tenants only | In your cloud account. Aurelianware operates to the access your engagement grants. |
| Hosted by Cloud Health Office (under evaluation — not offered today) | Several plans on shared infrastructure | The same controls: tenant in the token, data scoped by tenant, invitations for outside users, no keys in services. Register interest. |
The code paths are the same in every model. What changes is who holds the cloud account, the signing key and the platform administrator role.
Configure tenant security when you run it yourself
These steps take a deployment from development keys to production identity. The full reference is docs/security/portal-token-service.md.
1. Create the signing key
Production refuses to start without a managed key; PEM and symmetric keys are rejected. Set exactly one of:
| Cloud | Setting | Key | Identity needs |
|---|---|---|---|
| Google Cloud | TokenSigning:CloudKmsKeyVersion | ASYMMETRIC_SIGN, EC_SIGN_P256_SHA256 (ES256, recommended) or RSA_SIGN_PKCS1_*_SHA256, HSM protection | CryptoKey Signer/Verifier and Public Key Viewer on that key only |
| Azure | TokenSigning:KeyVaultKeyId | EC P-256 or RSA, versioned id, auto-rotation off | Key Vault Crypto User on that key |
On Google Cloud, the reference Terraform creates the key ring, an HSM key, the cho-token-service service account, the two grants and the Workload Identity binding:
# infrastructure/gcp/terraform.tfvars
enable_token_signing_kms = true
terraform apply
terraform output token_signing_key_version # -> TokenSigning:CloudKmsKeyVersion
terraform output token_service_google_account # -> annotate the token-service Kubernetes service account
terraform output kubernetes_service_account_issuer
The key version must be explicit (.../cryptoKeyVersions/1), never "latest". The private key never leaves the HSM: the service sends only a SHA-256 digest to be signed.
2. Make every service trust the issuers
Download the public key and give it to every service through your secret store or environment, never in source control:
gcloud kms keys versions get-public-key 1 --key token-signing --keyring cho \
--location us-west1 --output-file cho-token-service.pub.pem
"ChoAuth": {
"Audience": "cho-api",
"Issuers": [
{ "Issuer": "cho-token-service", "PublicKeyPem": "<public key>", "Kind": "User" },
{ "Issuer": "cho-token-service-svc", "PublicKeyPem": "<same key>", "Kind": "Service" },
{ "Issuer": "cho-workload", "PublicKeyPem": "<same key>", "Kind": "Workload" }
]
}
As environment variables: ChoAuth__Issuers__0__Issuer=cho-token-service, ChoAuth__Issuers__0__PublicKeyPem=..., and so on. To rotate, add a new key version under a new issuer name, trust both, switch TokenSigning:Issuer, and remove the old entry after about seven minutes.
3. Give each service its own identity
On GKE, EKS or on-premises clusters, configure token-service to accept projected service-account tokens and register each service:
"ServiceTokens": {
"Enabled": true,
"IdentityProvider": "Kubernetes",
"Kubernetes": {
"KubernetesIssuer": "https://container.googleapis.com/v1/projects/<project>/locations/<region>/clusters/<cluster>",
"Audience": "cho-token-service"
},
"ServiceClients": [
{ "ClientId": "claims-service", "Namespace": "cloudhealthoffice", "ServiceAccount": "claims-service" }
]
}
Each service sets ChoAuth:ServiceToken to Source=TokenService, TokenServiceUrl=http://token-service and Credential=KubernetesServiceAccount, runs as its own service account and mounts the token:
spec:
serviceAccountName: claims-service
containers:
- name: claims-service
volumeMounts:
- name: cho-token-service
mountPath: /var/run/secrets/cho/token-service
readOnly: true
volumes:
- name: cho-token-service
projected:
sources:
- serviceAccountToken:
audience: cho-token-service
expirationSeconds: 3600
path: token
The kubelet rotates the token and the service reads it on every exchange, so no restart is needed. On AKS, keep the default Entra provider and register each service's workload identity object id instead.
4. Set up staff sign-in
- On the Cloud Health Office API app registration, expose the
Cho.Tokenscope and grant it to the portal. - Define the
PlatformAdminapp role and assign it only in your own directory. SetTokenService:PlatformTenantIdto that directory's id. - For each tenant, record the plan's Entra directory id, add its administrators, and use invitations for anyone outside that directory.
5. Verify
# The published verification key (ES256 or RS256, never empty in production)
kubectl exec deploy/token-service -n cloudhealthoffice -- curl -s localhost:8080/.well-known/jwks.json
# Service tokens are audited with the workload that asked for them
kubectl logs deploy/token-service -n cloudhealthoffice | grep "CHO service token issued"
# ... client=claims-service sa=cloudhealthoffice/claims-service pod=claims-service-7c9f... tenant=acme
Also confirm that a request with a mismatched X-Tenant-ID header returns 403, and that an unregistered service account is refused with unknown_service.
Never in production
The symmetric development keys are in the public repository so anyone can run the platform locally. A deployment that trusts them is not isolated: anyone can mint a token for any tenant.
- Run deployed services as
Production(or a staging environment), neverDevelopmentorTesting. Both refuse to start on Kubernetes unless an override is set. - Do not set
CHO_ALLOW_DEV_ON_DEPLOYED_HOSTorCHO_ALLOW_TESTING_ENVIRONMENTon anything that holds real member data. - Do not configure
SymmetricKeyor the legacycho-internalissuer outside local development. - Do not register two services under one service account, or use a wildcard namespace.
The Google Cloud reference architecture shows where these pieces sit in a production environment, and the Production Readiness Checklist covers what else to complete before go-live. To review your tenant model with us, book a readiness review.