Architecture Decision Record
ADR-079: One Shared, Ordered HTTP Middleware Pipeline for Every Service Host
Status
Accepted (2026-08-14). Revised 2026-08-19 (refreshed the WebApplicationBuilderExtensions.cs
cross-reference anchor, which moved to :555). Revised 2026-08-21: the order became data (named
steps seeded by MiddlewarePipelineBuilder.CreateDefault()), gained a scoped configure overload
with startup-validated invariants, and is frozen by the MiddlewarePipelineOrderTestsBase fitness
function; the two costs this record originally carried as open trade-offs are retired below. Revised
2026-09-19: the HTTPS-redirect gRPC exemption is now keyed on the negotiated protocol
(MiddlewarePipelineBuilder.IsCleartextHttp2) rather than on a forgeable Content-Type header
(SEC-Common-44), and the fitness function is recorded as adopted by all three consumer repos.
Revised 2026-09-25: the ForwardedHeaders step builds its options from CommonForwardedHeaders.Create()
(v1.211.0), the same factory both Blazor UI hosts now adopt through UseCommonUiForwardedHeaders(), so
the UI hosts reuse the forwarded-headers posture as well as the localization half; the
MiddlewarePipelineBuilder.cs, WebApplicationExtensions.cs and UI-host anchors that change moved are
refreshed. Revised 2026-10-01 (anchor refresh only). Revised 2026-10-06: the soft-deleted-user check
is recorded as still honoring the shared deleted-user marker on hosts without a validator, rather than
as a no-op there. Revised 2026-10-07: anchors refreshed after the v1.233.0 release. Revised
2026-10-21: the tenant-resolution pass-through is recorded as also covering excluded paths and the
RequireTenant opt-out, the pre-forwarded-capture trade-off now names all four texts that still claim
a consumer, and the call-site and cross-ADR anchors are refreshed. Revised 2026-10-26: the
pre-forwarded-capture trade-off now names the one text that still claims a consumer (the fitness
function's because text), since the keys' XML doc, the step comment and the class summary now say
the captured Items have no reader; anchors refreshed after the call sites and pipeline files moved.
Revised 2026-10-28: the pre-forwarded-capture trade-off no longer names any text that claims a
consumer, since the fitness function's because text now pins the capture only for fidelity;
anchors refreshed after the ADC service, UI host and Store gateway lines moved.
Revised 2026-11-23: the seven service hosts now reach the pipeline through UseMmcaServiceHostAsync
(which has no configure overload) and the UI hosts through UseMmcaBlazorWebPipeline, Helpdesk is
the one direct caller, the no-validator pass-through also covers an unreachable cache and a cached
false entry, and anchors moved after the view-as guard step was added.
Context
In ASP.NET Core, middleware order is behavior, not style: a rate limiter placed before authentication
partitions every request as anonymous, an HTTPS redirect placed in front of a gRPC call breaks the
call, and a tenant resolver that reads HttpContext.User before UseAuthentication resolves nothing.
Each of those is a silent, correct-looking build.
The framework already ships that pipeline as a single call. Three accepted records cite it as where
their middleware sits: ADR-019 relies on forwarded headers running before the rate limiter
(019-rate-limiting.md:159-163), ADR-047 pins SoftDeletedUserMiddleware between authentication and
authorization (047-soft-deleted-user-session-revocation.md:62-66), and ADR-073 places
TenantResolutionMiddleware immediately after UseAuthentication because claim-first resolution needs
a populated principal (073-multi-tenancy-model.md:139-141). All three take the pipeline as given
context. None of them decides it, and nothing else does either, so the one ordering that every host in
both production apps depends on has been an implementation detail of a method rather than a recorded
decision. This record makes the pipeline itself the decision.
It is the HTTP counterpart of ADR-014, which does the same job for the CQRS decorator chain: one fixed, documented order that handler and host authors do not re-litigate per project.
Decision
Ship the edge as one ordered pipeline in the framework, UseCommonMiddlewarePipeline
(MMCA.Common/Source/Presentation/MMCA.Common.API/Startup/WebApplicationExtensions.cs:49), and have
every REST/gRPC host run it (directly, or through the composed service-host start-up) instead of
composing its own.
- One call, whole edge, controllers included. The method is an
extension(WebApplication app)member (WebApplicationExtensions.cs:38) that applies every edge middleware and finishes by mapping controllers, returning the app for chaining. A host's composition root is one line, not a hand-ordered list. - The order is data, not prose. Each step is a named
MiddlewarePipelineStep(a name plus the configure delegate), the names are constants onMiddlewarePipelineStepNames(Startup/Pipeline/MiddlewarePipelineStepNames.cs:17-80, declared in application order), andMiddlewarePipelineBuilder.CreateDefault()(Startup/Pipeline/MiddlewarePipelineBuilder.cs:31-159) seeds the nineteen defaults: exception handler, correlation id, request localization, pre-forwarded scheme/host capture, forwarded headers, gRPC-exempt HTTPS redirect, response compression, routing, CORS, authentication, tenant resolution, rate limiter, soft-deleted-user check, read-only view-as guard (ADR-137), authorization, output cache, JWKS and OIDC discovery endpoints, controllers. Both overloads route through one private helper that builds the list and applies it in order (WebApplicationExtensions.cs:171-182). - A scoped escape hatch, validated at startup. The
UseCommonMiddlewarePipeline(Action<MiddlewarePipelineBuilder>)overload (WebApplicationExtensions.cs:61) hands the host the seeded builder, which canInsertBefore,InsertAfter,Replace, orRemovesteps by name (MiddlewarePipelineBuilder.cs:169-232; unknown anchors and duplicate names throw).Build()(:260-283) then re-checks the load-bearing adjacencies below and throws naming the violated invariant, so a customized pipeline fails while the host is starting instead of misordering silently. An invariant binds only when both of its steps are still present, so dropping a whole capability (both members of a pair) stays legal. - Authentication before tenant resolution, and the code says why. The
TenantResolutionstep sits immediately afterAuthentication(MiddlewarePipelineBuilder.cs:106-112), because the claim strategy readsHttpContext.User, which carries token claims only once authentication has run (comment at:108-111, ADR-073).Build()enforces the adjacency (:267-270). - Authentication before rate limiting, and the code says why. The
RateLimitingstep runs after authentication on purpose: the global partition keys on the authenticated principal and routes anonymous traffic down aNoLimiterbranch, so an unpopulatedHttpContext.Userwould make every request look anonymous and the per-user cap would never engage (comment atMiddlewarePipelineBuilder.cs:116-119, ADR-019).Build()enforces the precedence (:272-275). - Forwarded headers before anything that reads the client IP, trusting any proxy.
The
ForwardedHeadersstep (MiddlewarePipelineBuilder.cs:63-68) builds its options from the framework's one posture,CommonForwardedHeaders.Create()(:68;Startup/CommonForwardedHeaders.cs:42-53):XForwardedFor | XForwardedProto | XForwardedHost(CommonForwardedHeaders.cs:33-34) with bothKnownProxiesandKnownIPNetworkscleared (:49-50), because cloud reverse proxies front the services from internal addresses that are not in the default allow-lists (:14-20, and the step's own comment atMiddlewarePipelineBuilder.cs:65-67). The same factory is what the server-rendered UI hosts adopt throughUseCommonUiForwardedHeaders()(Startup/CommonForwardedHeadersExtensions.cs:24-25), so a service and a UI host behind the same ingress read the scheme, host and client address identically. It sits ahead of the rate limiter, which is the ordering ADR-019 depends on, andBuild()enforces that it precedes the HTTPS redirect (MiddlewarePipelineBuilder.cs:277-280). - HTTPS redirect is exempted for cleartext HTTP/2, which is the gRPC case. The redirect is wrapped
in
app.UseWhenand skipped for any request that matchesMiddlewarePipelineBuilder.IsCleartextHttp2(MiddlewarePipelineBuilder.cs:84-86), a predicate defined as!Request.IsHttps && HttpProtocol.IsHttp2(Request.Protocol)(:358-364), because extracted services are reached over HTTP/2 cleartext (h2c) and a 307 on those requests breaks the call (comment at:72-76, ADR-012). The exemption keys on the protocol Kestrel negotiated during connection setup, which no header can fake; it does not readContent-Typeand it does not read routed-endpoint gRPC metadata, because the step runs beforeUseRoutingand no endpoint metadata exists yet (comment at:78-83). Matching on aContent-Typeofapplication/grpcwas the original shape and was replaced as forgeable: any caller could have set that header and been served plaintext (SEC-Common-44). The predicate ispublicso a host that rebuilds this step through the configure overload reuses it rather than reinventing the weaker check (:353-357). - The soft-deleted-user check sits between the limiter and authorization.
SoftDeletedUserMiddleware(Source/Presentation/MMCA.Common.API/Middleware/SoftDeletedUserMiddleware.cs:40) is theSoftDeletedUserFilterstep (MiddlewarePipelineBuilder.cs:122-124), afterRateLimitingand beforeAuthorization, so a revoked account is rejected before any endpoint authorizes it (ADR-047). - JWKS and OIDC discovery are always mapped. The
JwksEndpointandOidcDiscoveryEndpointsteps (MiddlewarePipelineBuilder.cs:143-154) are unconditional; a non-Identity host answers with an empty key set or a 404 rather than a different pipeline shape (comment at:145-149;OidcDiscoveryEndpointExtensions.cs:58-62is the 404 path). - The order is frozen by a fitness function.
MiddlewarePipelineOrderTestsBase(Source/Hosting/MMCA.Common.Testing/Conformance/MiddlewarePipelineOrderTestsBase.cs:31) is the edge counterpart of ADR-014'sDecoratorPipelineOrderTestsBase: it seeds the default builder, applies the subclass'sConfigurecustomization if any (:37), and asserts the step sequence is exactly the documented order (:63-70) and thatBuild()'s invariants hold (:72-80). NoWebApplicationis built, so it runs in the fast unit tier. The framework subclasses it in its own test pass (Tests/Hosting/MMCA.Common.Testing.Tests/Conformance/MiddlewarePipelineOrderTests.cs:12), and all three consumer repos subclass it next to their decorator-order tests, each with no overrides because every host runs the zero-argument overload (the seven service hosts throughUseMmcaServiceHostAsync, Helpdesk Web by calling it directly):MMCA.ADC/Tests/Architecture/MMCA.ADC.Architecture.Tests/Api/MiddlewarePipelineOrderTests.cs:16,MMCA.Store/Tests/Architecture/MMCA.Store.Architecture.Tests/Api/MiddlewarePipelineOrderTests.cs:16andMMCA.Helpdesk/Tests/Architecture/MMCA.Helpdesk.Architecture.Tests/MiddlewarePipelineOrderTests.cs:15. - Conditional middleware is registered unconditionally and adapts at runtime. Both
TenantResolutionMiddleware(theTenantResolutionstep,MiddlewarePipelineBuilder.cs:106-112) andSoftDeletedUserMiddleware(theSoftDeletedUserFilterstep,:122-124) are always in the chain: the first passes the request straight through unlessTenancy:Enabledis set, and also when the request path is excluded (Middleware/TenantResolutionMiddleware.cs:63, settings read at:61). On an enabled host a request that resolves no tenant is rejected, unless the host has opted out withRequireTenantfalse (defaulttrue,Persistence/Tenancy/TenancySettings.cs:102inMMCA.Common.Infrastructure), in which case it also passes through with no tenant set and runs as a system caller (TenantResolutionMiddleware.cs:76-82). The second resolvesISoftDeletedUserValidatorlazily (remarks atMiddleware/SoftDeletedUserMiddleware.cs:51-61, theGetServicecall at:117) rather than taking it as a parameter, so a host with no implementation registered does not fail. It is not a pure no-op there, though: an unauthenticated request passes straight through (:75-83), but an authenticated one still reads the shared deleted-user cache marker (:85-106) and is answered 401 when the marker is set (:108-115); with no validator, every other cache result passes the request through: a cache miss, an unreachable cache, or an explicit cachedfalseentry, because the validator null check (:117-125, remarks:58-60) runs before thecachedResult is falsebranch (:127-134). Either way the pipeline is literally one shape on every host rather than a per-host permutation. - Every REST/gRPC host runs it. All seven extracted services in the two production apps reach it
through the composed service-host start-up in
MMCA.Common.ServiceHost: each callsawait app.UseMmcaServiceHostAsync(host)(ADC IdentityMMCA.ADC/Source/Services/MMCA.ADC.Identity.Service/Program.cs:323, ADC ConferenceMMCA.ADC.Conference.Service/Program.cs:375, ADC EngagementMMCA.ADC.Engagement.Service/Program.cs:246, ADC NotificationMMCA.ADC.Notification.Service/Program.cs:145, Store CatalogMMCA.Store/Source/Services/MMCA.Store.Catalog.Service/Program.cs:118, Store IdentityMMCA.Store.Identity.Service/Program.cs:141and Store SalesMMCA.Store.Sales.Service/Program.cs:154), and that method (MMCA.Common/Source/Hosting/MMCA.Common.ServiceHost/ServiceHostApplicationExtensions.cs:43) maps the health endpoints (:55), then calls the zero-argumentUseCommonMiddlewarePipeline()(:56), then maps the OpenAPI document (:57) and, in Development only, gRPC reflection (:59-64). The reference app calls the pipeline directly (MMCA.Helpdesk/Source/Hosts/MMCA.Helpdesk.Web/Program.cs:170), the one host that does, and because that tree is themmca-apptemplate (MMCA.Helpdesk/.template.config/template.json:5,7, ADR-065), a scaffolded app gets the same line. - Hosts extend it by appending, after the call, or through the builder. OpenAPI outside
Production needs no host line: it is mapped inside the composed call
(
ServiceHostApplicationExtensions.cs:57, with the Production gate insideOpenApiEndpointExtensions.cs:61). Service hosts map their other extra endpoints below the composed call: the Notification host adds the SignalR hub (MMCA.ADC.Notification.Service/Program.cs:150, whose mapping methodSignalRExtensions.cs:18-19documents as "This should be called afterWebApplicationExtensions.UseCommonMiddlewarePipeline") and gRPC services (:160and:168). A host that needs a change inside the edge uses the configure overload instead. Only a host that calls the pipeline directly can do that:UseMmcaServiceHostAsynchas one overload, which takes noAction<MiddlewarePipelineBuilder>(MMCA.Common.ServiceHost/PublicAPI.Shipped.txt:32), so a service host would have to give up the composed call to customize its edge. No host does today, and every one of the eight production and reference hosts runs the zero-argument overload.
Scope is REST and gRPC service hosts. The Blazor UI hosts and the YARP gateways deliberately do not
call it: the gateways compose a much thinner chain (MMCA.ADC/Source/Hosts/MMCA.ADC.Gateway/Program.cs:173-231,
MMCA.Store/Source/Hosts/MMCA.Store.Gateway/Program.cs:161-189), and the UI hosts run the framework's
own Blazor host pipeline instead, UseMmcaBlazorWebPipeline
(MMCA.Common/Source/Presentation/MMCA.Common.UI.Web/Hosting/BlazorWebHostExtensions.cs:181; ADC
MMCA.ADC/Source/Hosts/UI/MMCA.ADC.UI.Web/Program.cs:128, :130 on the net10.0 #else branch,
Store MMCA.Store/Source/Hosts/UI/MMCA.Store.UI.Web/Program.cs:92), which reuses two pieces of this
pipeline through public methods. The first is the forwarded-headers posture, opened first via
UseCommonUiForwardedHeaders() (BlazorWebHostExtensions.cs:185), which applies the same
CommonForwardedHeaders.Create() options the ForwardedHeaders step uses
(Startup/CommonForwardedHeadersExtensions.cs:24-25). The second is the localization half via
UseCommonRequestLocalization() (BlazorWebHostExtensions.cs:201), which is the public method the
pipeline's RequestLocalization step calls (MiddlewarePipelineBuilder.cs:47,
WebApplicationExtensions.cs:74).
Rationale
- Order is behavior, so it belongs to the framework, not to each host. Four of the adjacencies above fail silently when reversed: the limiter stops limiting, the tenant resolver resolves nothing, the client IP becomes the proxy's, and gRPC calls get redirected. Centralizing removes the chance to get any of them wrong once per host, which is the same invariant-over-discipline posture as ADR-015.
- One place to change means one place to review. ADR-019, ADR-047 and ADR-073 each added middleware
by editing this method, and each got a comment explaining its position. The comments accumulate where
the ordering lives instead of being copied into seven
Program.csfiles. - Unconditional registration keeps the shape stable. Gating on configuration and runtime state rather than on registration means a host that turns multi-tenancy on later changes a setting, not its pipeline, and a diff between two hosts' edges is empty by construction.
- It preserves the extraction path. ADR-008 promises a module can be lifted into its own service without a rewrite. A host-owned pipeline would make the new service's edge a hand-transcribed copy; one shared call makes the extracted service inherit the identical edge behavior for free.
- It is the HTTP sibling of a pattern already proven in-process. ADR-014 fixes the decorator order for commands and queries for the same reason and with the same result: authors reason about one documented sequence.
Trade-offs
- Two of this record's original costs are retired (2026-08-21). As accepted, nothing froze the
order (no test referenced the method; the adjacencies were protected by comments and review, and
that was the weakest point of the decision) and there was no extension point (the method took no
parameters, so the escape hatch was all-or-nothing: stop calling it and compose a different chain,
which is what the Blazor UI hosts still deliberately do, through the framework's
UseMmcaBlazorWebPipeline,MMCA.Common/Source/Presentation/MMCA.Common.UI.Web/Hosting/BlazorWebHostExtensions.cs:181-201). Both are addressed by the revision above:MiddlewarePipelineOrderTestsBaseturns a reorder into a red test,Build()turns a misordered customization into a startup failure, and the configure overload makes the escape hatch scoped instead of all-or-nothing for a host that calls the pipeline directly (today only Helpdesk Web). For the seven service hosts the hatch is all-or-nothing again: they reach the pipeline throughUseMmcaServiceHostAsync, whose one overload takes no builder delegate and calls the zero-argument pipeline (MMCA.Common/Source/Hosting/MMCA.Common.ServiceHost/ServiceHostApplicationExtensions.cs:43,:56), so customizing their edge means giving up the composed start-up and calling the pipeline by hand. What remains true: the fitness function is opt-in per repo. All three consumer repos have taken it up, so nothing is currently uncovered, but a future repo that never subclasses it would get only the startup validation, and only for the invariantsBuild()knows about, not for the full sequence. - The extension API is a new public surface to hold stable. Step names are now contract:
renaming a constant on
MiddlewarePipelineStepNames, or reordering in a way the invariants do not cover, is a behavior change for any host using the configure overload. No host uses it yet, which makes this cheap today and easy to underestimate later. - Controllers are mapped inside the call. Because the
Controllersstep is last (MiddlewarePipelineBuilder.cs:156-158), every endpoint a host maps after the call is registered after controller routing. Hosts that need a hub or a gRPC service simply map it later; a host that calls the pipeline directly and genuinely needs something ahead of controllers canInsertBefore(Controllers, ...)through the configure overload instead of abandoning the method. A service host cannot:UseMmcaServiceHostAsynchard-codes the zero-argument call (ServiceHostApplicationExtensions.cs:56), so it would have to abandon the composed start-up. - Trusting any proxy is a deliberate security trade. With
KnownProxiesandKnownIPNetworkscleared (Startup/CommonForwardedHeaders.cs:49-50),X-Forwarded-Foris accepted from any caller, so the IP-keyed rate-limit partitions are spoofable by anything that can reach a service directly. This is safe only because the services are not publicly routable and sit behind the gateway; ADR-019 records the same caveat. The UI hosts take the identical posture throughUseCommonUiForwardedHeaders(), which rests on the same assumption stated in the code: the ingress is the only thing that can reach the container (CommonForwardedHeaders.cs:19-20). - Security-response headers are not in this pipeline. ADR-023's
UseCommonSecurityHeadersis applied by the gateways and UI hosts only (MMCA.ADC.Gateway/Program.cs:188,MMCA.Store.Gateway/Program.cs:175, and for both UI hosts insideUseMmcaBlazorWebPipelineatBlazorWebHostExtensions.cs:186). A service host exposed directly, without a gateway in front, would serve responses without them. - One step in the fixed order is currently dead weight. The pre-forwarded scheme/host capture
(the
PreForwardedCapturestep,MiddlewarePipelineBuilder.cs:49-61) writesHttpContext.Items["PreForwardedScheme"]and["PreForwardedHost"](:58-59). The keys' XML doc (WebApplicationExtensions.cs:18-24,:27-35), the step's own comment (MiddlewarePipelineBuilder.cs:51-55) and the fitness function's class summary (MiddlewarePipelineOrderTestsBase.cs:17-19) all say the captured Items have no reader, and the fitness function'sbecausetext (:69) pins the capture only so the captured pre-forwarded scheme and host "stay faithful", naming no consumer; no text in the framework source now claims one. The OIDC discovery endpoint does not need them:MapOidcDiscoveryEndpointderivesjwks_urifromJwt:Issuer(OidcDiscoveryEndpointExtensions.cs:72, with the rationale at:64-71), and a workspace-wide search forPreForwardedfinds no reader anywhere outside this file and the onboarding chapters that describe it. The step costs one delegate per request and stays because removing it is a separate change (now a one-lineRemovefor a host that wants it gone), but it is not load-bearing today, and itsBuild()adjacency invariant guards the capture's fidelity, not a live consumer. A related casualty of the accepted revision: the method's summary comment, which used to list a stale subset of the order, now points at the step-name contract instead of restating it.
Revision (2026-10-01)
Anchor refresh only; no decision or rationale changed. Refreshed citations: the private
ApplyPipeline helper (WebApplicationExtensions.cs:163-179), the lazy validator resolution in
SoftDeletedUserMiddleware.cs (:43-47, call at :75), the eight UseCommonMiddlewarePipeline() call
sites (ADC Identity :343, Conference :442, Engagement :318, Notification :263; Store Catalog
:313, Identity :297, Sales :297; Helpdesk Web :142), the Notification host extras (OpenAPI
:270-277, hub :284, gRPC :293 and :301), and the gateway chains (ADC :158-221 with security
headers at :168; Store :150-173).
Revision (2026-10-06)
- The
SoftDeletedUserMiddlewarebullet no longer calls the middleware a no-op on a host without anISoftDeletedUserValidator: such a host still reads the shared deleted-user cache marker for an authenticated request and answers 401 when it is set (SoftDeletedUserMiddleware.cs:84-109); only unauthenticated requests and a cache miss pass through. The Rationale bullet is reworded from "unconditional-and-inert" to "unconditional registration" to match. - Anchors re-verified against current source and refreshed: the
ApplyPipelinehelper (WebApplicationExtensions.cs:170-181), the middleware class (:33) and lazy resolution (:51-59,:111), the seven service call sites, the Notification host extras, the framework fitness-test subclass path (now underConformance/), the ADC gateway chain (:160-234, security headers:170), and the UI-host forwarded-headers, security-headers and localization lines.
Revision (2026-10-07)
Re-verified against current source. No decision, behavior or rationale changed: the eighteen-step
order, the startup invariants, the soft-deleted-user marker behavior on hosts without a validator,
the eight UseCommonMiddlewarePipeline() call sites and the UI-host reuse all hold as written. Only
line anchors moved.
- Anchors re-verified against current source: the
SoftDeletedUserMiddlewareclass (SoftDeletedUserMiddleware.cs:37), its lazy-resolution remarks (:49-57), unauthenticated pass-through (:72-80), shared-store marker read (:82-103), 401 on the marker (:105-112),GetServicecall (:114) and no-validator pass-through (:114-122); the ADC Conference (MMCA.ADC.Conference.Service/Program.cs:448) and Engagement (MMCA.ADC.Engagement.Service/Program.cs:325) call sites, the other six confirmed unchanged; and the ADC UI host'sUseCommonUiForwardedHeaders()(MMCA.ADC.UI.Web/Program.cs:210),UseCommonSecurityHeaders()(:216) andUseCommonRequestLocalization()(:238), with the Store UI host confirmed unchanged at:200,:204and:233.
Revision (2026-10-21)
Re-verified against current source. The eighteen-step order, the startup invariants and the eight
zero-argument UseCommonMiddlewarePipeline() call sites hold as written; two statements were sharpened
and several anchors moved.
- The
TenantResolutionMiddlewarepass-through is not onlyTenancy:Enabledbeing false: the same check also passes an excluded path straight through (MMCA.Common/Source/Presentation/MMCA.Common.API/Middleware/TenantResolutionMiddleware.cs:63, settings read at:61), and an enabled host that has setRequireTenantfalse (defaulttrue,MMCA.Common/Source/Core/MMCA.Common.Infrastructure/Persistence/Tenancy/TenancySettings.cs:102) passes an unresolved request through as a system caller (TenantResolutionMiddleware.cs:76-82). The Conditional-middleware bullet now says so. - The pre-forwarded-capture trade-off named only the keys' XML doc as stale. Three more texts still
say the OIDC discovery endpoint needs the captured values: the step's comment
(
MMCA.Common/Source/Presentation/MMCA.Common.API/Startup/Pipeline/MiddlewarePipelineBuilder.cs:51-56), and in the fitness function the class summary (MMCA.Common/Source/Hosting/MMCA.Common.Testing/Conformance/MiddlewarePipelineOrderTestsBase.cs:13-18, "an unreachablejwks_uri" at:16-17) and thebecausetext (:66). A search of the Common, ADC, Store and Helpdesk sources finds no reader of eitherItemskey; the only references are the writer (MiddlewarePipelineBuilder.cs:59-60) and the key constants (WebApplicationExtensions.cs:24,:35). - Anchors re-verified against current source: the ADC call sites (Identity
MMCA.ADC.Identity.Service/Program.cs:361, Conference:450, Engagement:326, Notification:270), Store Identity (MMCA.Store.Identity.Service/Program.cs:307) and Sales (MMCA.Store.Sales.Service/Program.cs:309), Store Catalog confirmed at:320; the Notification host extras (OpenAPI:272-277with the call at:277, hub:284, gRPC:293and:301); and the cross-ADR citations in Context (019-rate-limiting.md:117-121,047-soft-deleted-user-session-revocation.md:51-63,073-multi-tenancy-model.md:111-116).
Revision (2026-10-26)
Re-verified against current source. The eighteen-step order, the four Build() invariants, the eight
zero-argument UseCommonMiddlewarePipeline() call sites (no host passes a configure delegate) and the
UI-host reuse hold as written; one trade-off statement changed and most anchors moved.
- The pre-forwarded-capture trade-off no longer names four stale texts. The keys' XML doc
(
MMCA.Common/Source/Presentation/MMCA.Common.API/Startup/WebApplicationExtensions.cs:18-24,:27-35), the step's comment (MMCA.Common/Source/Presentation/MMCA.Common.API/Startup/Pipeline/MiddlewarePipelineBuilder.cs:51-55) and the fitness function's class summary (MMCA.Common/Source/Hosting/MMCA.Common.Testing/Conformance/MiddlewarePipelineOrderTestsBase.cs:17-19) now say the captured Items have no reader; only thebecausetext (:68) still ties the capture to a reachablejwks_uri. A search of the Common sources still finds no reader: the writer (MiddlewarePipelineBuilder.cs:58-59), the key constants (WebApplicationExtensions.cs:25,:36), the step name and theBuild()invariant are the only references. - Anchors re-verified against current source: the zero-argument overload
(
WebApplicationExtensions.cs:49), itsextension(WebApplication app)block (:38), the configure overload (:61),ApplyPipeline(:171-182) andUseCommonRequestLocalization(:74);CreateDefault()(MiddlewarePipelineBuilder.cs:31-150), the capture step (:49-61), forwarded headers (:63-68, comment:65-67), HTTPS redirect (:84-86, comments:72-76and:78-83), tenant resolution (:106-112, comment:108-111), the rate-limit comment (:116-119), the soft-deleted-user step (:122-124), output cache (:130-132), JWKS and OIDC discovery (:134-145, comment:136-140), controllers (:147-149), the edit methods (:160-223),Build()(:251-274, invariants:258-261,:263-266,:268-271) andIsCleartextHttp2(:349-355, remarks:344-348); the fitness class (MiddlewarePipelineOrderTestsBase.cs:31),Configure(:37), and its two tests (:62-69,:71-79); the service call sites (ADC IdentityMMCA.ADC.Identity.Service/Program.cs:372, Conference:461, Engagement:337, Notification:281; Store CatalogMMCA.Store.Catalog.Service/Program.cs:331, IdentityMMCA.Store.Identity.Service/Program.cs:318, SalesMMCA.Store.Sales.Service/Program.cs:320; Helpdesk Web confirmed at:149); the Notification host extras (OpenAPI:283-288with the call at:288, hub:295, gRPC:304and:312); the gateway chains (MMCA.ADC/Source/Hosts/MMCA.ADC.Gateway/Program.cs:161-240, security headers:176;MMCA.Store/Source/Hosts/MMCA.Store.Gateway/Program.cs:151-179, security headers:165); the UI hosts (ADCMMCA.ADC.UI.Web/Program.cs:216,:222,:244; StoreMMCA.Store.UI.Web/Program.cs:206,:210,:239); and the three cross-ADR citations in Context: ADR-019 item 5 now at019-rate-limiting.md:119-123, the ADR-047 position bullet at047-soft-deleted-user-session-revocation.md:52-64, and the ADR-073 placement statement at073-multi-tenancy-model.md:132-134.
Revision (2026-10-28)
Re-verified against current source. The eighteen-step order, the Build() invariants, the eight
zero-argument UseCommonMiddlewarePipeline() call sites and the UI-host reuse hold as written; one
trade-off statement changed and a few anchors moved.
- The pre-forwarded-capture trade-off no longer names a text that claims a consumer. The fitness
function's
becausetext (MMCA.Common/Source/Hosting/MMCA.Common.Testing/Conformance/MiddlewarePipelineOrderTestsBase.cs:68) now pins the capture immediately beforeUseForwardedHeaders"so the captured pre-forwarded scheme and host stay faithful" and no longer mentionsjwks_uri. With the keys' XML doc (WebApplicationExtensions.cs:18-24,:27-35), the step comment (MiddlewarePipelineBuilder.cs:51-55) and the class summary (MiddlewarePipelineOrderTestsBase.cs:17-19), no framework text ties the captured Items to a reader;jwks_uriis still derived fromJwt:Issuer(OidcDiscoveryEndpointExtensions.cs:76). - Anchors re-verified against current source: the ADC Identity
(
MMCA.ADC/Source/Services/MMCA.ADC.Identity.Service/Program.cs:373) and Engagement (MMCA.ADC.Engagement.Service/Program.cs:338) call sites, Conference (:461) and Notification (:281) confirmed; the Store gateway chain (MMCA.Store/Source/Hosts/MMCA.Store.Gateway/Program.cs:155-183, from the forwarded-headers comment toMapReverseProxy, withUseCommonSecurityHeadersat:169), the ADC gateway confirmed at:161-240and:176; and the UI hosts'UseCommonUiForwardedHeaders(),UseCommonSecurityHeaders()andUseCommonRequestLocalization()(ADCMMCA.ADC/Source/Hosts/UI/MMCA.ADC.UI.Web/Program.cs:217,:223,:245; StoreMMCA.Store/Source/Hosts/UI/MMCA.Store.UI.Web/Program.cs:207,:211,:240).
Revision (2026-11-23)
Re-verified against current source. The nineteen-step order (MiddlewarePipelineBuilder.cs:31-159),
the four Build() invariants and the zero-argument overload on every host hold as written; how the
service hosts and the UI hosts reach their pipelines moved, and every builder anchor after the
read-only view-as guard step (:126-133) shifted.
- The seven extracted services no longer call
UseCommonMiddlewarePipelinein theirProgram.cs. Each callsawait app.UseMmcaServiceHostAsync(host)(ADC IdentityMMCA.ADC/Source/Services/MMCA.ADC.Identity.Service/Program.cs:323, Conference:375, Engagement:246, Notification:145; Store CatalogMMCA.Store/Source/Services/MMCA.Store.Catalog.Service/Program.cs:118, Identity:141, Sales:154), which runs the zero-argument pipeline (MMCA.Common/Source/Hosting/MMCA.Common.ServiceHost/ServiceHostApplicationExtensions.cs:56) between the health endpoints (:55) and the OpenAPI document (:57). Helpdesk Web is now the one host that calls it directly (MMCA.Helpdesk/Source/Hosts/MMCA.Helpdesk.Web/Program.cs:170). The "Every REST/gRPC host" bullet now says so. - The configure overload is reachable only from a host that calls the pipeline directly:
UseMmcaServiceHostAsynchas one overload and it takes no builder delegate (MMCA.Common/Source/Hosting/MMCA.Common.ServiceHost/PublicAPI.Shipped.txt:32). OpenAPI is no longer mapped by the Notification host but inside the composed call (ServiceHostApplicationExtensions.cs:57, Production gate atOpenApiEndpointExtensions.cs:61). The extension bullet now says both, and the retired-costs and controllers-mapped-inside trade-offs now record that for the seven service hosts the escape hatch is all-or-nothing again, sinceUseMmcaServiceHostAsynchard-codes the zero-argument call (ServiceHostApplicationExtensions.cs:56). The Decision summary and the fitness-function bullet now say every host runs the zero-argument overload rather than calls it. - The Blazor UI hosts no longer hand-compose their chain. Both call
UseMmcaBlazorWebPipeline(MMCA.ADC/Source/Hosts/UI/MMCA.ADC.UI.Web/Program.cs:128,:130on net10.0;MMCA.Store/Source/Hosts/UI/MMCA.Store.UI.Web/Program.cs:92), and that framework method (MMCA.Common/Source/Presentation/MMCA.Common.UI.Web/Hosting/BlazorWebHostExtensions.cs:181) is whereUseCommonUiForwardedHeaders()(:185, still first),UseCommonSecurityHeaders()(:186) andUseCommonRequestLocalization()(:201) now run. The Scope paragraph, the retired-costs trade-off and the security-headers trade-off now cite it. - The soft-deleted-user bullet said only a cache miss with no validator passes through. With no
validator, every non-marker result passes the request through: a cache miss, an unreachable
cache, or an explicit cached
falseentry (MMCA.Common/Source/Presentation/MMCA.Common.API/Middleware/SoftDeletedUserMiddleware.cs:117-125, remarks:58-60), because the validator null check runs before thecachedResult is falsebranch (:127-134). - Anchors re-verified against current source: output cache (
MiddlewarePipelineBuilder.cs:139-141), JWKS and OIDC discovery (:143-154, comment:145-149), controllers (:156-158), the edit methods (:169-232),Build()(:260-283, invariants:267-270,:272-275,:277-280; the capture invariant at:262-265),IsCleartextHttp2(:358-364, remarks:353-357); theSoftDeletedUserMiddlewareclass (:40), lazy-resolution remarks (:51-61), unauthenticated pass-through (:75-83), marker read (:85-106), 401 on the marker (:108-115),GetService(:117); the fitness tests (MiddlewarePipelineOrderTestsBase.cs:63-70,becausetext:69,:72-80); the Notification hub (MMCA.ADC.Notification.Service/Program.cs:150) and gRPC services (:160,:168); the gateway chains (MMCA.ADC/Source/Hosts/MMCA.ADC.Gateway/Program.cs:173-231, security headers:188;MMCA.Store/Source/Hosts/MMCA.Store.Gateway/Program.cs:161-189, security headers:175); the OIDC 404 path (OidcDiscoveryEndpointExtensions.cs:58-62),jwks_uri(:72) and its rationale (:64-71); and the cross-ADR citations in Context (019-rate-limiting.md:159-163,047-soft-deleted-user-session-revocation.md:62-66,073-multi-tenancy-model.md:139-141).
Related
ADR-014 (the in-process sibling: one fixed decorator order for commands
and queries), ADR-019 (depends on forwarded headers before the limiter and on the
limiter after authentication), ADR-047 (depends on the slot
between authentication and authorization), ADR-073 (depends on the slot
immediately after authentication), ADR-027 (the request localization this
pipeline wires at :47), ADR-012 (the h2c transport the HTTPS-redirect
exemption exists for), ADR-040 (the output cache
at :139-141), ADR-023 (the edge middleware deliberately NOT in this
pipeline), ADR-008 (the extraction path this shared edge preserves).