↑↓ to navigate Enter to open "…" all these words ANDOR to combine

Architecture Decision Record

ADR-069: Shared DataProtection Key Ring for Scaled-Out Hosts

Status

Accepted (2026-08-07). Updated 2026-08-14: Store's adoption has landed and is live (its own dedicated storage account, gated on dataProtectionStorageReady), and the ADC call-site ordering is recorded precisely. Revised 2026-09-10: gate 2 ships in both templates, default off. Revised 2026-10-01: citations refreshed. Revised 2026-10-06: in both ADC hosts Key Vault configuration now loads before AddServiceDefaults() (still before the registration call), the ADC replica cap is conferenceScaledMaxReplicas, and gate 2 is recorded as switched on for ADC and off for Store. Revised 2026-10-07: anchors refreshed after the v1.233.0 release, and Related now points at ADR-024 for the WebSockets-only SignalR client that needs no session affinity. Revised 2026-10-21: anchors refreshed after the ADC and Store infrastructure templates and deploy workflows moved. Revised 2026-10-24: the call is AddAzureDataProtection() in MMCA.Common.Azure, configuration keys unchanged (ADR-134); framework anchors in the Decision corrected in place. See Revision (2026-10-24) at the end. Revised 2026-10-25: three key-ring adapters (Azure Blob + Key Vault, AWS Parameter Store, Google Cloud Storage with optional Cloud KMS), and the startup tripwire fails when more than one key-ring gate is set; the Decision is restated across the three, the package bullet corrected, and Google's prerelease packages recorded as a rejected alternative. See Revision (2026-10-25) at the end. Revised 2026-10-26: the consumer call sites name AddAzureKeyVaultConfiguration() and AddAzureDataProtection(), AddAzureMonitorExporter() now sits between AddServiceDefaults() and the registration (so Store's "only an ADR-069 comment block between them" is retired), and anchors refreshed across both hosts, templates and deploy workflows. Revised 2026-10-28: anchors refreshed after the ADC and Store host Program.cs files and both infrastructure templates moved. Amended 2026-11-12: AddAzureDataProtection() and its two DataProtection packages now live in MMCA.Common.Azure.Startup, which MMCA.Common.Azure references and type-forwards, so the call and its keys are unchanged; the Decision's Azure path, package bullet and citations are corrected in place (ADR-134). Revised 2026-11-23: Store now adopts the call on three hosts (UI, Identity, Sales), each with its own blob and discriminator, a missing gate-2 key logs one startup Warning outside Development, the gate-2 repository variable reads as set on both repositories, ADC's per-app identity opt-in and key-ring access alert are recorded, and anchors refreshed across Common, both hosts, both templates and both deploy workflows. Amended 2026-11-24 (MMCA.Common 1.318.0): the AWS key ring moves from Systems Manager Parameter Store to one S3 object written by the framework's own IXmlRepository, gated on DataProtection:S3ObjectUri, with DataProtection:KmsKeyId selecting SSE-KMS; the Amazon.AspNetCore.DataProtection.SSM dependency is gone and the retired DataProtection:SsmParameterPrefix key fails startup. The Decision's AWS bullet, the one-ring key list and the package bullet are corrected in place. See Amendment (2026-11-24) at the end.

Context

ASP.NET Core's DataProtection default keeps the key ring in memory, per process. That is correct for a single-process host and wrong for a scaled-out one: every replica generates its own keys, so an auth cookie or an antiforgery token minted by replica A cannot be decrypted by replica B. The symptom is random sign-outs and "The antiforgery token could not be decrypted" errors that follow no pattern, because they follow the load balancer rather than the user.

Two existing decisions put real payloads under that key ring. ADR-022 carries the browser session in HttpOnly cookies read during Blazor SSR prerender, and the Blazor Server forms those pages render mint antiforgery tokens; both are DataProtection payloads. ADR-008 then split the monolith into independently scaled hosts, and in ADC the two hosts that mint those payloads (the UI host and the Identity service, which also does OAuth correlation and state cookie cryptography) both scale to maxReplicas: conferenceScaledMaxReplicas, which is 2, or 4 in conference mode (MMCA.ADC/infra/main.bicep:214; :2394 Identity service, :3191 UI host, whose minimum also rises to the cap in conference mode at :3190). Of those two minting hosts, only the Identity service runs with no session affinity; the UI ingress is sticky (MMCA.ADC/infra/main.bicep:3081-3083), which narrows the UI window rather than closing it, since affinity is lost on a replica restart, a revision swap, or a dropped affinity cookie.

Nothing in the record decided where the key ring lives. ADR-061 decides how a running app reaches a secret (Key Vault reference resolved by a managed identity) and ADR-045 decides that blob storage is reached with DefaultAzureCredential plus a data-plane role, but the key ring is neither an app secret nor user content: it is process-local state that has to become deployment-wide state. This record decides that, and it records which repos have adopted it.

Decision

Persist the key ring through one opt-in registration call per cloud, so every replica of a host shares one ring, and let a host keep exactly one ring. Three adapters exist: AddAzureDataProtection (MMCA.Common.Azure.Startup, also reached through MMCA.Common.Azure) persists it to a single Azure blob with optional Key Vault protection (MMCA.Common/Source/Hosting/MMCA.Common.Azure.Startup/AzureDataProtectionExtensions.cs:54), AddAwsDataProtection (MMCA.Common.Aws) to one Amazon S3 object with optional SSE-KMS (MMCA.Common/Source/Hosting/MMCA.Common.Aws/AwsDataProtectionExtensions.cs:70), and AddGoogleCloudDataProtection (MMCA.Common.Gcp) to one Cloud Storage object with optional Cloud KMS protection (MMCA.Common/Source/Hosting/MMCA.Common.Gcp/GoogleCloudDataProtectionExtensions.cs:77). The bullets up to the AWS one describe the Azure adapter, the one both deployed consumers call.

  • One configuration key is the gate, and absent means do nothing. DataProtection:BlobStorageUri is read first (AzureDataProtectionExtensions.cs:56); when it is absent or whitespace the method returns the builder untouched (:64-67), so no DataProtection services are registered at all and no startup receipt is left. A developer machine, a test host, and the Helpdesk seed all run single-process, where the in-memory default is correct and an unconditional Azure dependency at startup would be a liability. Tests pin that boundary: an unconfigured builder registers no IDataProtectionProvider and leaves KeyManagementOptions.XmlRepository null, while a configured URI replaces the default repository with the blob one (MMCA.Common/Tests/Hosting/MMCA.Common.Azure.Startup.Tests/AzureDataProtectionExtensionsTests.cs:26, :44, which asserts the replacement is the Azure.Extensions.AspNetCore.DataProtection.Blobs repository specifically at :69), and the receipt is left only with a URI (:74, :86). None of them needs Azure credentials: the blob client is constructed lazily by the repository, never at registration time.
  • Blob persistence plus an application discriminator. A configured URI leaves the tripwire receipt (AzureDataProtectionExtensions.cs:71) and wires SetApplicationName and PersistKeysToAzureBlobStorage (:79-81); the discriminator comes from DataProtection:ApplicationName and falls back to the host application name (:73-74). The discriminator is what keeps two applications sharing one blob or one key-ring directory from reading each other's keys.
  • Encryption of the key ring at rest is a SECOND, deliberately independent gate. DataProtection:KeyVaultKeyUri is read separately (:90, through the constant at AzureKeyRingAtRestNoticeService.cs:17) and adds ProtectKeysWithAzureKeyVault when present (AzureDataProtectionExtensions.cs:91-94). When it is absent outside Development the call registers AzureKeyRingAtRestNoticeService instead (:95-99), which logs one startup Warning naming that key (AzureKeyRingAtRestNoticeService.cs:22, :30-32); in Development nothing is logged. Tests pin the Warning and both silent cases (AzureDataProtectionExtensionsTests.cs:115, :123, :135). The two gates are uncoupled on purpose (AzureDataProtectionExtensions.cs:83-89): blob persistence is the part that fixes cross-replica cookie and antiforgery decryption, and it has to work without the Key Vault Crypto User role, because that role assignment is granted out of band and can lag a deployment. Folding the second step into the first would turn an optional hardening gap into a total authentication outage, so a missing key is a Warning, not a failure. The deployment template records the same reasoning (MMCA.ADC/infra/main.bicep:1716-1721). Both templates ship the gate-2 path, default off (see the 2026-09-10 revision); a deployment turns it on through the DATA_PROTECTION_KEY_VAULT_KEY_URI repository variable (MMCA.ADC/.github/workflows/deploy.yml:1673, :1907-1908; MMCA.Store/.github/workflows/deploy.yml:1406, :1558-1559). That is repository configuration, not source: as read on 2026-11-23 the variable is set on both the ADC and the Store repository.
  • One DefaultAzureCredential instance serves both sinks (AzureDataProtectionExtensions.cs:77), so they share a single token cache. A deployed host authenticates with its managed identity and a developer machine falls back to the local Azure CLI or Visual Studio sign-in; ADC pins which identity with AZURE_CLIENT_ID on both adopting apps (MMCA.ADC/infra/main.bicep:2270, :3123).
  • ADC adopts it on exactly the two hosts that mint the payloads. The Identity service calls it (MMCA.ADC/Source/Services/MMCA.ADC.Identity.Service/Program.cs:109) and so does the Web UI host (MMCA.ADC/Source/Hosts/UI/MMCA.ADC.UI.Web/Program.cs:47), each inside the composed host's AfterServiceDefaults callback, after AddAzureMonitorExporter() (UI :46, Identity :101). AddAzureKeyVaultConfiguration() is the ConfigureConfigurationSources callback in both hosts (UI :39, Identity :94; the reason is in the comments at UI :36-38 and Identity :91-93), and the framework runs that callback before AddServiceDefaults() and the AfterServiceDefaults callback (MMCA.Common/Source/Hosting/MMCA.Common.ServiceHost/ServiceHostBuilderExtensions.cs:77 -> :83 -> :84; MMCA.Common/Source/Presentation/MMCA.Common.UI.Web/Hosting/BlazorWebHostExtensions.cs:82 -> :85 -> :86), because ConfigurationManager loads each source as it is added, so the vault has to be layered in before anything reads configuration, the blob URI included. The Conference, Engagement and Notification hosts and the Gateway call only the exporter (Gateway Key Vault MMCA.ADC/Source/Hosts/MMCA.ADC.Gateway/Program.cs:75, exporter :82) and never AddAzureDataProtection, because they mint neither a session cookie nor an antiforgery token.
  • In ADC, infrastructure provisions one private container, not a new storage account. dataprotection-keys is created on the existing avatar storage account with publicAccess: 'None' (MMCA.ADC/infra/main.bicep:1700-1706), deliberately unlike the public avatars and session-assets containers beside it (:1670-1676, :1686-1692), and both apps are pointed at .../dataprotection-keys/keys.xml with the shared discriminator MMCA.ADC (:2268-2269, :3121-3122), unconditionally. No extra role assignment is needed on default parameters: the ADR-045 Storage Blob Data Contributor grant to the shared apps identity is scoped to the storage account, so it already covers this container (comment :1708-1715, scope :1724, principal :1727). That grant is itself guarded by grantAvatarStorageRole, default false, because the deploy identity deliberately lacks role-assignment rights (:155, :1710-1711, :1722). Under the opt-in usePerAppIdentities (default false, :39) the Identity and UI apps run as their own identities (:1887, :1902) and their dataprotection-keys grants come from MMCA.ADC/scripts/security/bootstrap-identities.ps1:21-24, not from the template. The account's blob data-plane audit explicitly covers reads of dataprotection-keys/keys.xml (comment :1640-1642, diagnostic setting at :1648), and an alert fires on a successful request to that container by any principal other than the apps, Identity or UI identity, or by account key or SAS (:943-984).
  • AWS: one S3 object, written by the framework's own repository. AddAwsDataProtection() is gated on DataProtection:S3ObjectUri in s3://bucket/path/keys.xml form (AwsDataProtectionExtensions.cs:23, :35-:39; read at :72, a no-op when blank at :78-:81, parsed at :84, marker at :88) and persists through the internal PersistKeysToAmazonS3 step (:95; MMCA.Common/Source/Hosting/MMCA.Common.Aws/DataProtection/AwsDataProtectionBuilderExtensions.cs:32). S3XmlRepository keeps the whole ring as one object, the shape the Azure Blob and Cloud Storage repositories use (MMCA.Common/Source/Hosting/MMCA.Common.Aws/DataProtection/S3XmlRepository.cs:12-:14), and writes it read-modify-write under an S3 conditional write: If-Match on the ETag it read, or If-None-Match: * to create it (:16-:20, :101, :105). A writer that loses the race (412, or 409 on overlapping writes) re-reads and retries up to MaxAttempts (10) with a linear 50 ms backoff (:39, :125; AwsDataProtectionBuilderExtensions.cs:18), then fails naming the object (S3XmlRepository.cs:130-:131). The optional DataProtection:KmsKeyId selects SSE-KMS under that key for every write, else the bucket's default encryption applies (AwsDataProtectionExtensions.cs:24, :40-:42; S3XmlRepository.cs:110). The S3 client is the IAmazonS3 the host registered, else one built from the SDK default region and credential chain (AwsDataProtectionBuilderExtensions.cs:37), and the discriminator is the same DataProtection:ApplicationName with the host application name as fallback (AwsDataProtectionExtensions.cs:90-:91). The identity needs s3:GetObject and s3:PutObject on the object and s3:ListBucket on the bucket, plus kms:GenerateDataKey and kms:Decrypt when a key is set (:54-:58).
  • Google Cloud: one Cloud Storage object, written by the framework's own repository. AddGoogleCloudDataProtection() is gated on DataProtection:GcsObjectUri in gs://bucket/path/keys.xml form (GoogleCloudDataProtectionExtensions.cs:24, :37-:41; read at :79, a no-op when blank at :85-:88, parsed at :91, marker at :103). GcsXmlRepository keeps the whole ring as one object, the shape the Azure Blob repository uses (MMCA.Common/Source/Hosting/MMCA.Common.Gcp/DataProtection/GcsXmlRepository.cs:12-:15), and writes it read-modify-write under IfGenerationMatch set to the generation it read, 0 meaning create only (:17-:20, :84-:87, :118-:119). A writer that loses the race gets 412, re-reads the ring that now holds the winner's key and retries, up to MaxAttempts (10) with a linear backoff of 50 ms per attempt (:34, :90-:98; MMCA.Common/Source/Hosting/MMCA.Common.Gcp/DataProtection/GcpDataProtectionBuilderExtensions.cs:21), and then fails, naming the object (GcsXmlRepository.cs:101-:102). The optional DataProtection:GcpKmsKeyName encrypts each key with a Cloud KMS symmetric key (GoogleCloudDataProtectionExtensions.cs:25, validated at :94-:99, applied at :112-:115; the encryptor is wired at GcpDataProtectionBuilderExtensions.cs:54-:59), a separate optional step for the reason Azure gate 2 is (GoogleCloudDataProtectionExtensions.cs:64-:66), and like Azure it logs one startup Warning outside Development when no key is named (:116-:121). The repository and the KMS encryptor and decryptor are hand-written because Google's DataProtection packages are prerelease only and a stable package cannot depend on a prerelease (NU5104) (MMCA.Common/Directory.Packages.props:255-:259, MMCA.Common/CHANGELOG.md:19); see Alternatives rejected.
  • A host keeps exactly one key ring. Each adapter's gate set without its call fails ValidateOnStart, naming the call (MMCA.Common/Source/Hosting/MMCA.Common.Aspire/Integrations/HostIntegrationTripwire.cs:26, :32, :43; checks at :101-:105, :111-:115, :121-:125), and setting more than one of DataProtection:BlobStorageUri, DataProtection:S3ObjectUri and DataProtection:GcsObjectUri fails startup as well (the key list at :84-:89, the check at :173-:178): whichever registration runs last would own the repository, so services that disagree on the order would mint payloads the others cannot decrypt (:158-:160).
  • Each cloud's dependencies live in its own adapter package. Azure.Extensions.AspNetCore.DataProtection.Blobs and .Keys are referenced by MMCA.Common.Azure.Startup (MMCA.Common/Source/Hosting/MMCA.Common.Azure.Startup/MMCA.Common.Azure.Startup.csproj:22, :26, pinned at MMCA.Common/Directory.Packages.props:277-:278), the package that also carries AddAzureDataProtection() itself (MMCA.Common/Source/Hosting/MMCA.Common.Azure.Startup/AzureDataProtectionExtensions.cs:20, :54) with no persistence or messaging dependency (its only project reference is MMCA.Common.Aspire, MMCA.Common.Azure.Startup.csproj:4, :37). MMCA.Common.Azure references it (MMCA.Common/Source/Hosting/MMCA.Common.Azure/MMCA.Common.Azure.csproj:47) and type-forwards the call (MMCA.Common/Source/Hosting/MMCA.Common.Azure/TypeForwards.cs:8), in the same MMCA.Common.Azure namespace (AzureDataProtectionExtensions.cs:7), so a host on the full adapter writes the same call. A host that needs only start-up plumbing (for example a gateway) references MMCA.Common.Azure.Startup alone. AWSSDK.S3 by MMCA.Common.Aws (MMCA.Common/Source/Hosting/MMCA.Common.Aws/MMCA.Common.Aws.csproj:17, pinned at MMCA.Common/Directory.Packages.props:186; the AWS key ring needs no DataProtection package of its own), and Google.Cloud.Kms.V1 by MMCA.Common.Gcp (MMCA.Common/Source/Hosting/MMCA.Common.Gcp/MMCA.Common.Gcp.csproj:23, pinned at Directory.Packages.props:260), so a host references only the cloud it runs on.

Both consumers have now adopted it (2026-08-13). MMCA.Store originally had no call site and no DataProtection configuration anywhere in the repo, even though its UI, Identity and Sales container apps also run at maxReplicas: 2 (MMCA.Store/infra/main.bicep:2548 UI host, :2020 Identity service, :2311 Sales service). Three Store hosts now call AddAzureDataProtection(), each inside the composed host's AfterServiceDefaults callback after AddAzureMonitorExporter(), with AddAzureKeyVaultConfiguration() as the ConfigureConfigurationSources callback that runs first:

  • The UI host (MMCA.Store/Source/Hosts/UI/MMCA.Store.UI.Web/Program.cs:50; exporter :45, Key Vault :39), for the SSR session cookie and antiforgery tokens.
  • The Identity service (MMCA.Store/Source/Services/MMCA.Store.Identity.Service/Program.cs:62; exporter :56, Key Vault :48), because the two-factor secret is stored protected with the ring, so every replica and every later revision must be able to unprotect it (comment :58-61).
  • The Sales service (MMCA.Store/Source/Services/MMCA.Store.Sales.Service/Program.cs:82; exporter :76, Key Vault :63), because it protects the Stripe webhook signing secret it shares through the cache (comment :78-81). Sales registers SharedDataProtectionKeyRing only when the AzureDataProtection receipt is present (:111-119); without it the secret is kept unprotected rather than written in a form no other replica can read.

The Catalog service and the Gateway call only the exporter (Gateway Key Vault MMCA.Store/Source/Hosts/MMCA.Store.Gateway/Program.cs:67, exporter :74), never AddAzureDataProtection. The infrastructure side has landed and is live. Store diverges from ADC in four ways worth recording:

  • A new dedicated storage account, not a reused one. Store has no public-blob workload to share an account with, so the template provisions its own Standard_LRS account dataProtectionStorage with allowBlobPublicAccess: false (MMCA.Store/infra/main.bicep:1549, :1559, :1564) and its own private dataprotection-keys container (:1579-1585, publicAccess: 'None' at :1583), with a diagnostic setting that sends the account's blob reads, writes and deletes to Log Analytics (:1595).
  • One ring per host, not one shared ring. Each adopting host has its own blob and its own discriminator: the UI keys.xml with MMCA.Store (:2517, :2521), Identity identity-keys.xml with MMCA.Store.Identity (:1991-1992), and Sales sales-keys.xml with MMCA.Store.Sales (:2293-2294), so no Store host can read another's payloads.
  • The blob URI is gated behind a readiness flag. The UI's DataProtection__ApplicationName is unconditional (:2517), but every DataProtection__BlobStorageUri is appended only when the dataProtectionStorageReady parameter is true (default false at :131; UI :2520-2521), and Identity and Sales gate their discriminator on the same flag (:1990-1993, :2292-2295). The flag exists because AddAzureDataProtection gates on the presence of the URI, never on reachability: wiring the URI before the data-plane grant exists would 403 on the first protect call rather than degrade. That flag is true in production: the deploy workflow passes "dataProtectionStorageReady": {"value": true} in its base parameters (MMCA.Store/.github/workflows/deploy.yml:1454). Gate 2 is hasDataProtectionKek alone on the UI (main.bicep:158, :2522-2528) and the readiness flag AND hasDataProtectionKek on Identity and Sales (:1994-1996, :2298-2299).
  • Its own role-assignment guard. The Storage Blob Data Contributor grant is guarded by Store's own grantDataProtectionStorageRole parameter (default false at :128), with the account-scoped role assignment at :1636, deliberately separate from the readiness flag above: one says whether THIS deployment creates the grant, the other says whether the grant already exists. Store has the same opt-in usePerAppIdentities mode as ADC (:29, default false; comment :1989).

The framework side needed no change for any of the three: each delta was one call site plus infrastructure, against a capability that already shipped in the package Store consumes.

Rationale

  • The key ring is the smallest thing that has to be shared. Sticky sessions would paper over the symptom while making a replica restart a mass sign-out, and a shared cache would put auth keys in a cache with an eviction policy. One blob, read by every replica, matches the actual lifetime of the data.
  • Uncoupling the two gates is the load-bearing choice. The correctness fix (persistence) and the hardening step (encryption at rest) have different failure modes and different prerequisites. If they were one switch, a role assignment that has not been applied yet would take authentication down for everyone, which is strictly worse than a key ring that is stored under an account-scoped data-plane grant and not additionally encrypted.
  • A silent no-op keeps the framework's default posture. Local development, the test tiers and the Helpdesk seed are all single-process. Making the Azure path opt-in through the presence of one configuration value means no host pays an Azure dependency at startup for a problem it does not have.
  • Reusing the avatar storage account avoids new infrastructure, where there is one to reuse. In ADC the account, its managed-identity grant and its deployment path already exist (ADR-045); a private container beside the public one is the whole delta. Store has no public-blob workload and therefore no account to ride on, so it provisions a dedicated one instead: the shared rule is the private container and the account-scoped grant, not the specific account.

Trade-offs

  • The key ring is encrypted at rest only where gate 2 was switched on. Both templates ship the path and both default it off (2026-09-10 revision), so on default parameters the ring is protected by the container being private and the account grant being narrow, not by a Key Vault key. Turning it on is a deployment decision (one repository variable plus the Key Vault Crypto User grant). That variable lives in repository configuration rather than source; as read on 2026-11-23 it is set for both ADC and Store, so a deploy that reads it injects DataProtection__KeyVaultKeyUri into the ADC Identity and UI apps and into all three Store rings (MMCA.Store/infra/main.bicep:1994, :2298, :2522). Whether a Store deploy has applied it is not determinable from source; the Store deploy run history (read 2026-11-23) shows successful push deploys of main after the variable was last updated, so one very likely has. A host running without the key logs one startup Warning naming it (AzureDataProtectionExtensions.cs:95-99).
  • Opt-in per host, so adoption must be audited. A scaled-out host that never calls AddAzureDataProtection keeps the broken per-replica default and fails intermittently rather than loudly, the same audit-the-inventory caveat as ADR-005 / ADR-017 / ADR-021. Store was exactly that case until its UI host adopted the call site (2026-08-13); the caveat still binds every future scaled-out host that mints or stores a DataProtection payload, as Store's Identity and Sales services now do.
  • Startup now depends on a credential resolving in the adopting hosts. In Azure that is the user-assigned identity named by AZURE_CLIENT_ID; a missing or wrong identity turns a key-ring read into a startup-time failure on each of the five hosts that opt in (ADC Identity and UI; Store UI, Identity and Sales).
  • A shared blob plus a shared discriminator means shared keys by design. ADC's Identity service and UI host both use the discriminator MMCA.ADC, which is what makes their cookies mutually decryptable; Store instead gives each host its own blob and discriminator. A future app that should NOT share keys must get its own blob or its own DataProtection:ApplicationName, or it will silently join the same ring.
  • Local and deployed behavior differ. Development runs the in-memory default, so a cross-replica decryption bug is by construction not reproducible locally: the deployed configuration is the only place the persisted path is exercised.

Revision (2026-09-10)

Gate 2 ships in both templates, default off, so "configured nowhere" is retired. The framework side is unchanged: AddCommonDataProtection (MMCA.Common/Source/Hosting/MMCA.Common.Aspire/DataProtection/DataProtectionExtensions.cs:52) still carries gate 1 at :59-62 and gate 2 at :81-85, and this revision propagated no framework change.

Both consumers now carry the same three pieces, each guarded by a parameter that defaults to false or empty:

Piece ADC Store
createDataProtectionKeyVaultKey param, default false infra/main.bicep:139 infra/main.bicep:100
dataprotection-kek Key Vault key, created only under that flag :1339-1341 :1228-1230
dataProtectionKeyVaultKeyUri param, default empty :142 :103
DataProtection__KeyVaultKeyUri env entry :1634 (Identity), :2355 (UI) :1999 (UI)
Repository-variable plumbing in deploy.yml :1395, :1575-1576 :1290, :1417-1418

The env inventory differs because the adopting-host inventory differs, not because the posture does: ADC mints auth payloads on two hosts (Identity and the UI) and Store on one (the UI, whose Identity service registers no cookie or OAuth scheme and so mints no key-ring payload). The workflow half is the same shape in both, a jq set that runs only when the repository variable is non-empty, which is what keeps the default deploy unchanged.

What this does not establish is whether the variable is set in either production, and that stays unverifiable from the repositories. The honest reading of the trade-off above is therefore "shipped and off by default", not "enabled".

Re-pinned call sites while here: ADC Identity (MMCA.ADC/Source/Services/MMCA.ADC.Identity.Service/Program.cs:113), ADC UI (MMCA.ADC/Source/Hosts/UI/MMCA.ADC.UI.Web/Program.cs:46), Store UI (MMCA.Store/Source/Hosts/UI/MMCA.Store.UI.Web/Program.cs:70, AddServiceDefaults at :64); and on the gate-1 side, Store's dataProtectionStorageReady default at MMCA.Store/infra/main.bicep:97, its production flip at MMCA.Store/.github/workflows/deploy.yml:1324, and the role-assignment guard grantDataProtectionStorageRole at MMCA.Store/infra/main.bicep:94 with the assignment at :1197.

Revision (2026-10-01)

No decision or rationale changed; this revision refreshes citations only. Re-anchored in Context, Decision and the Store adoption notes: the ADC replica caps, sticky UI ingress, gate-2 follow-up comment, AZURE_CLIENT_ID entries, dataprotection-keys container, blob URI and discriminator env entries, and the grantAvatarStorageRole guard and account-scoped assignment (MMCA.ADC/infra/main.bicep:133, :1294-1322, :1743-1745, :1843, :2485-2487, :2524-2526, :2586); the ADC call sites and their ordering (MMCA.ADC/Source/Services/MMCA.ADC.Identity.Service/Program.cs:99, :107, :114; MMCA.ADC/Source/Hosts/UI/MMCA.ADC.UI.Web/Program.cs:51, :59, :61); the Aspire package references and central pins (MMCA.Common.Aspire.csproj:42-43, Directory.Packages.props:152-153, :158); and the Store call site, dedicated account, container, env entries, readiness flag, role guard and production flip (MMCA.Store/Source/Hosts/UI/MMCA.Store.UI.Web/Program.cs:62, :68; MMCA.Store/infra/main.bicep:94, :97, :1162-1193, :1244-1252, :1591, :2056-2061, :2087; MMCA.Store/.github/workflows/deploy.yml:1260). The 2026-09-10 revision above keeps its anchors as a historical record; the current gate-2 locations are ADC infra/main.bicep:142, :145, :1502-1504, :1799 (Identity), :2544 (UI) and deploy.yml:1281, :1461-1462, and Store infra/main.bicep:100, :103, :1275-1277, :2067 (UI) and deploy.yml:1226, :1353-1354.

Revision (2026-10-06)

  • ADC call ordering corrected. Both ADC hosts now run AddCommonKeyVaultConfiguration() before AddServiceDefaults() (Identity Program.cs:110 -> :112 -> :119; UI Program.cs:61 -> :63 -> :65), so the earlier "Key Vault sits between AddServiceDefaults() and the registration call" wording is retired; the vault still loads before the blob URI is read.
  • ADC replica cap corrected. Identity and UI scale to conferenceScaledMaxReplicas (MMCA.ADC/infra/main.bicep:191, 2, or 4 in conference mode), not a literal 2.
  • Gate 2 state recorded per consumer. The DATA_PROTECTION_KEY_VAULT_KEY_URI repository variable is set on ADC and absent on Store as read on 2026-10-06 (repository configuration, not source), so "shipped and off by default" now holds for Store only.
  • Omissions filled. ADC's session-assets public container beside dataprotection-keys, the ADC blob audit covering keys.xml, Store's blob diagnostic setting, and Store's shared azureClientIdEnv entry.
  • Anchors in Context, Decision, the Store adoption notes and Trade-offs were re-verified against current source. Current gate-2 locations: ADC infra/main.bicep:142, :145, :1529-1531, :1826 (Identity), :2594 (UI) and deploy.yml:1339, :1519-1520; Store infra/main.bicep:100, :103, :1275-1277, :2077 (UI) and deploy.yml:1281, :1408-1409.

Revision (2026-10-07)

Re-verified against current source. No decision, rationale or trade-off changed: both gates, the two ADC adopting hosts and their call ordering (Identity Program.cs:110 -> :112 -> :119; UI Program.cs:61 -> :63 -> :65), the Store UI adoption (Program.cs:44, :63, :69), the private dataprotection-keys container, the unconditional blob URI and discriminator, and the absence of session affinity on Identity (the one non-sticky host of the two minting hosts) all hold. What moved is line numbers in the ADC template and both deploy workflows, plus one cross-reference.

  1. Related now points at ADR-024. The SignalR hub client skips negotiation and connects over WebSockets only (MMCA.Common/Source/Presentation/MMCA.Common.UI/Services/Notifications/NotificationHubService.cs:537-538, rationale in the doc comment at :511-516): with no separate negotiate request, connect cannot land on a replica that never issued the connection id, so the hub needs no session affinity either. That is the same no-affinity stance this record takes for Identity, reached by a different mechanism.
  2. Anchors re-verified against current source: ADC infra/main.bicep:192 (conferenceScaledMaxReplicas), :1914 (Identity scale), :2692 (UI scale), :2582-2584 (sticky UI ingress, the only stickySessions block in the file), :1342-1348 (dataprotection-keys, publicAccess: 'None'), :1312-1318 (avatars), :1328-1334 (session-assets), :1350-1357 and :1364 (account-scoped grant), :1350-1354 and :1362 (grantAvatarStorageRole guard; param still :133), :1358-1361 (gate-2 follow-up comment), :1282-1284 (blob audit), :1802-1804 and :2622-2624 (blob URI, discriminator, AZURE_CLIENT_ID); Store deploy.yml:1202 (production flip of dataProtectionStorageReady). Current gate-2 locations: ADC infra/main.bicep:142, :145, :1553 (comment :1543-1552), :1857-1858 (Identity), :2641-2642 (UI) and deploy.yml:1233, :1411-1412; Store deploy.yml:1168, :1295-1296. The earlier revisions keep their anchors as a historical record.

Revision (2026-10-21)

Re-verified against current source. No decision, rationale or trade-off changed: both gates (DataProtectionExtensions.cs:59-62, :81-85), the ADC call ordering (Identity Program.cs:111 -> :113 -> :120; UI Program.cs:61 -> :63 -> :65), the Store UI adoption (Program.cs:44, :63, :69), the private dataprotection-keys containers, the unconditional ADC blob URI and discriminator, the Store readiness flag, and the absence of session affinity on the ADC Identity service all hold. What moved is line numbers in both infrastructure templates, both deploy workflows and the ADC Identity host.

  1. Anchors re-verified against current source: ADC Identity MMCA.ADC/Source/Services/MMCA.ADC.Identity.Service/Program.cs:111, :113, :120 (comment :108-110); ADC infra/main.bicep:192 (conferenceScaledMaxReplicas), :2070 (Identity scale, inside identityApp at :1825), :2848 (UI scale, inside uiApp at :2719), :2738-2740 (sticky UI ingress, still the only stickySessions block), :1492-1498 (dataprotection-keys, publicAccess: 'None'), :1462-1467 (avatars), :1478-1483 (session-assets), :1500-1507 and :1514 (account-scoped grant comment and scope), :1502-1504 and :1512 (grantAvatarStorageRole guard; param still :133), :1508-1511 (gate-2 follow-up comment), :1432-1434 (blob audit), :1958-1960 and :2778-2780 (blob URI, discriminator, AZURE_CLIENT_ID); Store infra/main.bicep:98 (grantDataProtectionStorageRole), :101 (dataProtectionStorageReady), :1241-1259 (dedicated account), :1266-1272 (container), :1282 (diagnostic setting), :1323-1331 (role assignment), :1500-1503 (azureClientIdEnv), :2160, :2162, :2163-2164 (UI env entries), :2191 (UI scale), :1682 (Identity scale) and deploy.yml:1220 (production flip of dataProtectionStorageReady). Current gate-2 locations: ADC infra/main.bicep:142, :145, :1703 (comment :1693-1702), :2013-2014 (Identity), :2797-2798 (UI), gated by hasDataProtectionKek at :166, and deploy.yml:1248, :1426-1427; Store infra/main.bicep:104, :107, :1354, :2171 (UI) and deploy.yml:1186, :1324-1325.

Revision (2026-10-24)

ADR-134 moves the key-ring registration out of MMCA.Common.Aspire into the MMCA.Common.Azure adapter. The decision, both gates and the keys are unchanged.

  1. The call is renamed and moved. AddCommonDataProtection() is now AddAzureDataProtection() (MMCA.Common/Source/Hosting/MMCA.Common.Azure/AzureDataProtectionExtensions.cs:20, :53). It still reads DataProtection:BlobStorageUri (:59) and does nothing without it (:64-:67), takes the discriminator from DataProtection:ApplicationName (:69-:70), persists to the blob (:75-:77), and adds Key Vault protection only for DataProtection:KeyVaultKeyUri (:86-:90).
  2. A lost call now fails startup. DataProtection:BlobStorageUri set without the call fails ValidateOnStart, naming it (MMCA.Common/Source/Hosting/MMCA.Common.Aspire/Integrations/HostIntegrationTripwire.cs:26, :31; the call's marker at AzureDataProtectionExtensions.cs:57). That narrows the "opt-in per host" trade-off to hosts that never received the URI at all.
  3. Corrected in place: the Decision and Trade-offs references to AddCommonDataProtection and the MMCA.Common.Aspire/DataProtection/DataProtectionExtensions.cs anchors now point at the adapter. The consumer call-site sentences name the call each consumer made when last verified; a consumer on v1.255.0 or later makes the renamed call. The anchors inside earlier revisions are left as recorded.

Alternatives rejected

  • Google's own ASP.NET Core DataProtection packages (for example Google.Cloud.AspNetCore.DataProtection.Kms) instead of a hand-written repository and encryptor. Weighed 2026-10-25 and declined. They are prerelease only, and a stable MMCA.Common.Gcp cannot depend on a prerelease package (NU5104) (MMCA.Common/Directory.Packages.props:255-:259, MMCA.Common/CHANGELOG.md:19). The cost is code the framework now maintains: one repository (MMCA.Common/Source/Hosting/MMCA.Common.Gcp/DataProtection/GcsXmlRepository.cs:31) and a KMS encryptor and decryptor pair beside it. Revisit when Google publishes stable releases of those packages; the adapter call and its keys can stay while the implementation moves to them.

Revision (2026-10-25)

MMCA.Common v1.257.0 ships the key ring for two more clouds (MMCA.Common/CHANGELOG.md:7, :13, :19). The decision for ADC and Store, both gates of the Azure adapter and its keys are unchanged.

  1. Three adapters. Azure Blob + Key Vault (MMCA.Common/Source/Hosting/MMCA.Common.Azure/AzureDataProtectionExtensions.cs:53), AWS Parameter Store SecureString parameters, gate DataProtection:SsmParameterPrefix, optional KmsKeyId (MMCA.Common/Source/Hosting/MMCA.Common.Aws/AwsDataProtectionExtensions.cs:57, :59, :76), and one Cloud Storage object, gate DataProtection:GcsObjectUri, optional DataProtection:GcpKmsKeyName (MMCA.Common/Source/Hosting/MMCA.Common.Gcp/GoogleCloudDataProtectionExtensions.cs:24-:25, :76), written under IfGenerationMatch with a bounded retry (MMCA.Common/Source/Hosting/MMCA.Common.Gcp/DataProtection/GcsXmlRepository.cs:34, :87). The Decision's opening paragraph is restated across the three and gains one bullet per new adapter.
  2. The startup tripwire now fails when more than one key-ring gate is set (MMCA.Common/Source/Hosting/MMCA.Common.Aspire/Integrations/HostIntegrationTripwire.cs:49-:54, :107-:112; MMCA.Common/CHANGELOG.md:33), on top of failing each gate set without its call.
  3. Google's prerelease packages are a rejected alternative, recorded above with the NU5104 reason and the revisit condition.
  4. Corrected in place: the Decision bullet "The Azure dependencies live in the Aspire package only". Since ADR-134 the two Azure DataProtection packages are referenced by MMCA.Common.Azure, and the direct System.Security.Cryptography.Xml pin that bullet cited is no longer in MMCA.Common/Directory.Packages.props. The anchors inside earlier revisions are left as recorded.

Revision (2026-10-26)

Re-verified against current source. No decision, rationale or trade-off changed: both Azure gates, the two ADC adopting hosts, the Store UI adoption, the private dataprotection-keys containers, the unconditional ADC blob URI and discriminator, the Store readiness flag and its production flip, and the absence of session affinity on the ADC Identity service all hold. What moved is the consumer call-site wording and line numbers across both hosts, both templates and both deploy workflows.

  1. Consumer call sites name the current calls. ADC and Store now call AddAzureKeyVaultConfiguration() and AddAzureDataProtection(); neither old name remains in their source. The ordering still holds (vault, then AddServiceDefaults(), then the registration), and AddAzureMonitorExporter() now sits between the defaults call and the registration in all three adopting hosts (MMCA.ADC/Source/Hosts/UI/MMCA.ADC.UI.Web/Program.cs:62, :64, :69, :71; MMCA.ADC/Source/Services/MMCA.ADC.Identity.Service/Program.cs:112, :114, :119, :126; MMCA.Store/Source/Hosts/UI/MMCA.Store.UI.Web/Program.cs:45, :64, :69, :75).
  2. Store's "immediately after, with only an ADR-069 comment block between them" is retired. The Store UI host places AddAzureMonitorExporter() (Program.cs:69, comment :66-68) before the ADR-069 comment (:71-74) and the registration (:75); the Decision's Store paragraph is corrected in place.
  3. Anchors re-verified against current source: ADC Key Vault ordering comments UI Program.cs:59-61 and Identity Program.cs:109-111; ADC infra/main.bicep:192 (conferenceScaledMaxReplicas), :2106 (Identity scale, inside identityApp at :1861), :2884 (UI scale, inside uiApp at :2755), :2774-2776 (sticky UI ingress, still the only stickySessions block), :1526-1532 (dataprotection-keys, publicAccess: 'None' at :1530), :1496-1502 (avatars), :1512-1518 (session-assets), :1534-1541 and :1550 (account-scoped grant comment and scope), :1535-1537 and :1548 (grantAvatarStorageRole guard; param still :133), :1542-1547 (gate-2 follow-up comment), :1466-1468 and :1474 (blob audit comment and diagnostic setting), :1994-1996 and :2814-2816 (blob URI, discriminator, AZURE_CLIENT_ID); MMCA.Common/Directory.Packages.props:209-210 (Azure DataProtection pins); deploy.yml gate-2 plumbing ADC :1249, :1427-1428 and Store :1187, :1325-1326; Store infra/main.bicep:98, :101, :1245-1263 (dedicated account), :1270-1276 (container), :1286 (diagnostic setting), :1327-1335 (role assignment), :1506-1509 (azureClientIdEnv), :2166, :2168, :2169-2170 (UI env entries), :2197 (UI scale, inside uiApp at :2101), :1688 (Identity scale) and deploy.yml:1221 (production flip of dataProtectionStorageReady). The earlier revisions keep their anchors as a historical record.

Revision (2026-10-28)

Re-verified against current source. No decision, rationale or trade-off changed: the ADC replica cap (conferenceScaledMaxReplicas, 2 or 4 in conference mode), the sticky UI ingress and the absence of affinity on Identity, the unconditional ADC blob URI and discriminator, the call ordering in all three adopting hosts (vault, then AddServiceDefaults(), then AddAzureMonitorExporter(), then the registration), the Store dedicated account, private container, readiness flag and role guard all hold. What moved is line numbers in both hosts' Program.cs and both infrastructure templates.

  1. Anchors re-verified against current source: ADC UI MMCA.ADC/Source/Hosts/UI/MMCA.ADC.UI.Web/Program.cs:63, :65, :70, :72 (Key Vault ordering comment :60-62); ADC Identity MMCA.ADC/Source/Services/MMCA.ADC.Identity.Service/Program.cs:112, :114, :119, :127 (comment :109-111, unchanged); ADC infra/main.bicep:192 (conferenceScaledMaxReplicas), :2103 (Identity scale, inside identityApp at :1858), :2881 (UI scale, inside uiApp at :2752), :2771-2773 (sticky UI ingress, still the only stickySessions block; a comment at :2751 also names it), :1991-1992 and :2811-2812 (blob URI and discriminator), :1993 and :2813 (AZURE_CLIENT_ID); Store UI MMCA.Store/Source/Hosts/UI/MMCA.Store.UI.Web/Program.cs:46, :65, :70, :72-75, :76; Store infra/main.bicep:1246-1264 (dedicated account), :1271-1277 (container), :1287 (diagnostic setting), :1328-1336 (role assignment), :1507-1510 (azureClientIdEnv), :2167, :2169, :2170-2171 (UI env entries), :2198 (UI scale, inside uiApp at :2102), :1689 (Identity scale, inside identityApp at :1515); :98 and :101 unchanged. The earlier revisions keep their anchors as a historical record.

Revision (2026-11-23)

Re-verified against current source. Both Azure gates and their independence, the blob no-op, the ADC adopting hosts (Identity and UI only), the vault-first ordering, the ADC private container and account-scoped grant, the ADC replica cap and sticky UI ingress, the Store dedicated account, private container, readiness flag and role guard, and the one-ring tripwire all hold. What changed is the Store host inventory, the gate-2 absent path and the gate-2 repository state, plus anchors throughout.

  1. Store adopts the call on three hosts, not one. The Identity service (MMCA.Store/Source/Services/MMCA.Store.Identity.Service/Program.cs:62) protects its two-factor secret with the ring, and the Sales service (MMCA.Store/Source/Services/MMCA.Store.Sales.Service/Program.cs:82) protects the Stripe webhook signing secret, registering SharedDataProtectionKeyRing only when the receipt is present (:111-119). Each Store host has its own blob and discriminator (MMCA.Store/infra/main.bicep:1991-1992, :2293-2294, :2517, :2521). The Decision's "Store's Identity service is deliberately left out" and the Trade-offs' "three hosts" are corrected in place; the 2026-09-10 revision's "Store on one" stays as recorded.
  2. Gate 2 absent is a startup Warning, not silence. Outside Development a configured blob with no DataProtection:KeyVaultKeyUri registers AzureKeyRingAtRestNoticeService (MMCA.Common/Source/Hosting/MMCA.Common.Azure.Startup/AzureDataProtectionExtensions.cs:95-99), which logs one Warning naming the key (MMCA.Common/Source/Hosting/MMCA.Common.Azure.Startup/AzureKeyRingAtRestNoticeService.cs:17, :22, :30-32); the Google Cloud adapter does the same (GoogleCloudDataProtectionExtensions.cs:116-121).
  3. Gate-2 repository variable. As read on 2026-11-23, DATA_PROTECTION_KEY_VAULT_KEY_URI is set on both the ADC and the Store repository (repository configuration, not source). Whether a Store deploy has applied it is not determinable from source; the Store deploy run history (read 2026-11-23) shows successful push deploys of main after the variable was last updated, so one very likely has.
  4. Omissions filled. ADC's opt-in usePerAppIdentities mode (MMCA.ADC/infra/main.bicep:39, :1887, :1902), under which the key-ring grants come from MMCA.ADC/scripts/security/bootstrap-identities.ps1:21-24 rather than the template, and ADC's key-ring access alert (MMCA.ADC/infra/main.bicep:943-984). The ADC hosts now express the ordering through the composed host's callbacks (MMCA.Common/Source/Hosting/MMCA.Common.ServiceHost/ServiceHostBuilderExtensions.cs:77, :83, :84; MMCA.Common/Source/Presentation/MMCA.Common.UI.Web/Hosting/BlazorWebHostExtensions.cs:82, :85, :86).
  5. Anchors re-verified against current source: AzureDataProtectionExtensions.cs:54 (method), :56 (gate read), :71 (receipt, the marker the 2026-10-24 revision cites at :57), :73-74 (discriminator), :77 (credential), :79-81 (persist), :83-89 (uncoupling comment), :90-94 (gate 2); tests in MMCA.Common/Tests/Hosting/MMCA.Common.Azure.Startup.Tests/AzureDataProtectionExtensionsTests.cs:26, :44, :69, :74, :86, :115, :123, :135; HostIntegrationTripwire.cs:77-82, :101-105, :111-115, :121-125, :158-166; MMCA.Common.Azure.Startup.csproj:22, :26, :37; MMCA.Common.Azure.csproj:47; MMCA.Common.Aws.csproj:24; GoogleCloudDataProtectionExtensions.cs:77, :79, :85-88, :91, :94-99, :103, :112-115; MMCA.Common/Directory.Packages.props:232, :255-259, :260, :277-278; ADC UI Program.cs:39, :46, :47 and Identity Program.cs:94, :101, :109; ADC infra/main.bicep:214 (cap), :2394 and :3191 (scale), :3081-3083 (sticky), :155 (grant guard), :1670-1676, :1686-1692, :1700-1706 (containers), :1708-1730 (grant), :1648 (blob diagnostics), :2268-2270 and :3121-3123 (env); ADC deploy.yml:1673, :1907-1908; Store UI Program.cs:39, :45, :50; Store infra/main.bicep:128, :131, :158, :1549, :1579-1585, :1595, :1636, :2020, :2311, :2548; Store deploy.yml:1406, :1454, :1558-1559. The earlier revisions keep their anchors as a historical record.

Amendment (2026-11-24): the AWS key ring is one S3 object

Decision. AddAwsDataProtection() persists the key ring to one S3 object instead of one SecureString parameter per key, through a framework-owned IXmlRepository (MMCA.Common/Source/Hosting/MMCA.Common.Aws/DataProtection/S3XmlRepository.cs:36), and the Amazon.AspNetCore.DataProtection.SSM dependency leaves MMCA.Common.Aws. The three adapters now share one shape: the whole ring is a single object or blob, written read-modify-write under the store's own precondition (an Azure ETag, a Cloud Storage generation, an S3 If-Match / If-None-Match), so two replicas creating a key at the same moment cannot lose either key.

Why. It is one of the third-party dependencies MMCA.Common 1.318.0 replaces with framework code (MMCA.Common/CHANGELOG.md, the 1.318.0 breaking entries). The repository follows the one the Google Cloud adapter already hand-writes, and it needs only AWSSDK.S3, which MMCA.Common.Aws already references for file storage.

Configuration. The gate is DataProtection:S3ObjectUri (s3://bucket/path/keys.xml, AwsDataProtectionExtensions.cs:23); DataProtection:KmsKeyId selects SSE-KMS for the object (:24), without it the bucket's default encryption applies; DataProtection:ApplicationName is unchanged. The startup tripwire requires the call when the new gate is set (MMCA.Common/Source/Hosting/MMCA.Common.Aspire/Integrations/HostIntegrationTripwire.cs:32, :118-:122), counts it in the one-ring check (:84-:89), and fails a host that still sets the retired DataProtection:SsmParameterPrefix, naming the new key (:39, :123-:127). Keys already held in Parameter Store are not read: a deployment moves either by letting the ring regenerate (users sign in once more) or by copying the key elements into the object before the switch (MMCA.Common/UPGRADING.md).

Corrected in place: the Decision's opening paragraph (the AWS target), the AWS bullet, the one-ring key list and the package bullet. The 2026-10-25 revision and the Status lines before this one keep the Parameter Store wording as a historical record. Neither deployed consumer runs on AWS, so no host changes.

ADR-022 (the browser session cookies whose decryption this makes replica-independent, together with the antiforgery tokens the SSR pages mint), ADR-008 (the multi-host topology that created the problem; the adopting hosts are the ones that mint auth payloads), ADR-061 (managed identity as the runtime credential model, which this reuses for a payload that is state rather than a secret), ADR-045 (the storage account, the account-scoped data-plane grant, and the DefaultAzureCredential pattern this container rides on), ADR-024 (the WebSockets-only SignalR client transport, recorded in its 2026-10-07 revision: with no negotiate request, connect cannot land on a different replica than negotiate, so the hub needs no session affinity either).