Architecture Decision Record
ADR-019: Layered Rate Limiting with an Authenticated-Only Global Limiter
Status
Accepted. Revised 2026-08-01 (the auth-ip per-IP anonymous-authentication limiter, which the shared
auth controller applies to login and register by default, is recorded as the third layer; the
anonymous-surface trade-off was corrected to match; the edge trust posture behind every IP partition
key was made explicit). Revised 2026-08-18 (the hard-coded limits become a bound RateLimitingSettings
section, a sliding-window algorithm option joins the fixed window, and the global and UserPolicy
partitions gain an optional Redis-backed distributed limiter with a fail-open posture, which partly
retires the "in-process counters" trade-off below; auth-ip stays deliberately local. See the
Revision (2026-08-18) at the end).
Revised 2026-09-07 (the gRPC exemption keys on endpoint metadata and the negotiated protocol
instead of a caller-set header; anonymous /hubs traffic is metered per IP; ADC's tighter gateway
policy is scoped to the two credential-submission routes; and a trusted-internal-caller exemption
generalizes the synthetic-traffic bypass).
Revised 2026-09-19 (the Decision is brought in line with the two revisions below and with the
current auth-ip surface: the gRPC exemption reads endpoint metadata rather than a content type,
anonymous hub traffic is metered before the anonymous exemption applies, the second global
partition key is the subject claim, and auth-ip now covers password reset and email confirmation
alongside login and register).
Revised 2026-09-30 (the global and UserPolicy partitions key on the subject claim first and fall
back to identity name, because the name claim carries the non-unique full name, so two users with the
same name shared one bucket; MMCA.Common v1.213.0).
Revised 2026-09-10 (both gateways scope auth-tight to the two credential routes, and the
trusted-caller client half ships in the framework as AddTrustedCallerHeader).
Revised 2026-10-01 (the output-cache list reads as a sample, and the auth-ip no-IP rule no longer
claims to mirror the global limiter).
Revised 2026-10-06: every ADC service binds the RateLimiting section, and the email-confirmation
auth-ip decoration is recorded as owned by the framework base rather than by each app.
Revised 2026-10-07: the distributed limiter's Redis partition key is qualified by the application
namespace (MMCA.Common v1.232.0), so by default two MMCA applications sharing one Redis no longer
share counters.
Revised 2026-10-19: Store's three services bind the RateLimiting section too, so both apps call the
configuration overload in every service.
Revised 2026-10-21: the distributed limiter's increment and expiry run as one atomic Lua script, so
no fault between them can leave a counter key without a TTL, and the forwarded-header trade-off
records that both Bicep templates declare service ingress internal-only.
Revised 2026-10-26: anchors refreshed after the source moves since 2026-10-21, and Related names
ADR-135 as the record that owns the application-namespace decision the Redis partition key follows.
Revised 2026-10-28: anchors refreshed after the Bicep, UI host and Identity service source moves
since 2026-10-26.
Revised 2026-11-17: the opt-in FixedPolicy and UserPolicy named policies, their partition
selector and their PermitLimit, QueueLimit and PerUserPermitLimit settings are removed because
no consumer named them, so auth-ip and mcp are the only named policies (MMCA.Common v1.300.0).
See the Revision (2026-11-17).
Revised 2026-11-23: the auth-ip surface is recorded as twelve framework actions (machine-client
token, OAuth discovery, passkey sign-in and sign-in links join the original six), Store's own
quote-ip policy is recorded as the one consumer-registered policy, ADC's and Store's services and UI
hosts reach AddCommonRateLimiting and AddTrustedCallerHeader through the framework host builders
rather than a per-app call (Helpdesk's single web host still calls AddCommonRateLimiting itself),
ADC's gateway puts auth-tight on a third route (the machine-client token), and
anchors are refreshed.
Revised 2026-12-03 (MMCA.Common v1.331.0): every per-IP partition keys on one shared client-address
key that treats an IPv6 /64 as one client and unmaps an IPv4-mapped address; the idempotency filter's
anonymous subject keeps the raw address. See the Revision (2026-12-03).
Context
Every service exposes read and write endpoints to the public internet through the gateway (ADR-008). Abusive or runaway clients (scrapers, credential stuffing, retry storms, a buggy SPA stuck in a loop) can exhaust a service's threads, database connections, and downstream quotas. ASP.NET Core ships a rate-limiting middleware, but "turn on rate limiting" is not the decision: the load-bearing questions are who gets limited, by what partition key, and what is exempt. A naive per-IP global limiter is actively wrong for this deployment for three reasons:
- Public read endpoints are output-cached, so legitimate anonymous browsing should be cheap, not throttled.
- Anonymous server-rendered (Blazor Server) traffic all shares the UI host's outbound IP, so an IP partition would throttle every public visitor as if they were a single abuser.
- Login and registration brute-force is a distinct threat with a distinct control (account lockout and per-IP registration throttling), not a general request cap.
Decision
Rate limiting is layered, and the always-on global limiter is authenticated-only.
- A global limiter that only caps authenticated callers.
AddCommonRateLimiting(MMCA.Common.API) installs aGlobalLimiter(active on every request throughUseRateLimiter) that:- Exempts infrastructure traffic outright (
NoLimiter):/health,/alive, JWKS / OIDC discovery (/.well-known/*), and gRPC inter-service calls, recognized from the routed endpoint's gRPC metadata rather than from the caller-setapplication/grpccontent type (see the Revision (2026-09-07)). These are legitimately high-frequency. - Exempts anonymous traffic (
NoLimiter) for the three reasons above, with one metered exception: an anonymous request to a configured hub path prefix is counted per client IP atAnonymousHubPermitLimitfirst, and only every other anonymous request falls through to the exemption (see the Revision (2026-09-07)). - Caps each authenticated caller to
globalPermitLimit(default 300) requests per fixed one-minute window, partitioned by the subject (sub) claim, then identity name, then remote IP, rejecting overage with429 Too Many Requests.
- Exempts infrastructure traffic outright (
- Anonymous abuse is handled by the right-shaped control, not the global limiter. Public reads
are served from the output cache (
UseOutputCache; ADC's Conference service defines one public-endpoint policy per public aggregate, among themEventsCache/CategoriesCache/QuestionsCache/RoomsCache, registered in theConfigureOutputCachecallback it hands toAddMmcaServiceHost,MMCA.ADC/Source/Services/MMCA.ADC.Conference.Service/Program.cs:136,:175-216), and login/registration brute-force is handled byLoginProtectionService(exponential-backoff account lockout afterMaxFailedAttemptsfailed logins, plus per-IP registration throttling). - A per-IP cap on the anonymous authentication endpoints, on by default.
AddCommonRateLimitingalso registers the named policyRateLimitPolicyAuthIp("auth-ip"): a fixed one-minute window keyed on the client IP,authIpPermitLimit(default 30) requests, overage rejected with429. It is not left to each app to attach.AuthControllerBase(MMCA.Common.API) decoratesLoginAsyncandRegisterAsync, andPasswordResetAuthControllerBasedecorates theforgot-passwordandreset-passwordactions, andEmailConfirmationControllerBasedecorates the two anonymous email-confirmation actions,send-email-confirmationandconfirm-email(MMCA.Common/Source/Presentation/MMCA.Common.API/Controllers/EmailConfirmationControllerBase.cs:81,:109). Six more anonymous credential actions carry it the same way:MachineTokenControllerBaseon the machine-client token action (MMCA.Common/Source/Presentation/MMCA.Common.API/Controllers/MachineClients/MachineTokenControllerBase.cs:48),OAuthControllerBaseondiscover(.../Controllers/OAuthControllerBase.cs:176),PasskeysControllerBaseonsignin/optionsandsignin(.../Controllers/Passkeys/PasskeysControllerBase.cs:232,:257), andSignInLinkControllerBaseonsign-in-linkandsign-in-link/redeem(.../Controllers/SignInLinks/SignInLinkControllerBase.cs:83,:111). All twelve carry[EnableRateLimiting(WebApplicationBuilderExtensions.RateLimitPolicyAuthIp)], so any consumer that inherits one of those bases gets them without opting in. The list is not every anonymous credential action: inOAuthControllerBaseonlydiscovercarries it, so the anonymousexchangePOST that redeems a single-use code for an access and refresh token pair (.../Controllers/OAuthControllerBase.cs:289-293), thecompletecallback (:204-205) and the provider challenge actions (:115-155) carry none. An app may also name the policy on its own anonymous actions: Store's guest-order controller does (MMCA.Store/Source/Modules/Sales/MMCA.Store.Sales.API/Controllers/GuestOrdersController.cs:58,:208). Store's and ADC's IdentityEmailConfirmationControllerderive from that base and add no attribute of their own (MMCA.Store/Source/Modules/Identity/MMCA.Store.Identity.API/Controllers/EmailConfirmationController.cs:33,MMCA.ADC/Source/Modules/Identity/MMCA.ADC.Identity.API/Controllers/EmailConfirmationController.cs:32). What an override inherits, settled empirically (2026-08-13):EnableRateLimitingAttributeleavesAttributeUsage.Inheritedat its default oftrue, and a derived override therefore still sees the base attribute throughGetCustomAttributes(inherit: true), so a bare override very likely retains the policy rather than silently dropping it. The convention is unchanged regardless: apply the attribute explicitly on every override (ADC always did; Store now does), because endpoint metadata resolution is not something an app should have to reason about per action, and a dropped policy fails silently. Two guards pin it instead of leaving it to argument: a MMCA.Common reflection test that asserts both the base decoration and the inherited-on-an-override case, and a Store integration test that reads the booted host'sEndpointDataSourceand assertsPOST /Auth/registercarries theauth-ippolicy in its metadata (the only check independent of the reflection question). It exists because the other two layers leave one hole between them: the global limiter no-ops for anonymous traffic outside the hub paths and the lockout is keyed per email, so a password spray (one password, many emails) from a single source was otherwise unthrottled. Three details are deliberate:RefreshAsyncis not throttled (renewal is automatic and periodic, and Blazor Server circuits issue it server-side from the UI host's IP); a request with no attributable IP getsNoLimiterrather than sharing one bucket with every other such request (a deliberate difference from the global limiter, which puts an unattributable authenticated request in one shared"authenticated"bucket and an unattributable anonymous hub request in one shared"anonymous-hub"bucket,MMCA.Common/Source/Presentation/MMCA.Common.API/Startup/WebApplicationBuilderExtensions.RateLimiting.cs:187,:96, whileauth-ipreturnsNoLimiterat:345-346); and the default is 30 rather than a tighter 10 for the same shared-IP reason, since every Server-circuit user's login leaves from the UI host's address. - The only other named policy belongs to the MCP endpoint.
AddCommonRateLimitingalso registersRateLimitPolicyMcp("mcp",MMCA.Common/Source/Presentation/MMCA.Common.API/Startup/WebApplicationBuilderExtensions.RateLimiting.cs:57, registered at:442), one window per user id, then name, then client IP (:209-225) atMcpPermitLimitrequests per minute (default 60,MMCA.Common/Source/Presentation/MMCA.Common.API/RateLimiting/RateLimitingSettings.cs:42-43). It is inert until an endpoint names it, andMapCommonMcpis the one caller that does (MMCA.Common/Source/Presentation/MMCA.Common.Mcp/McpHostingExtensions.cs:136, ADR-138). The framework registers no general-purpose tightening policy: an action that needs a tighter cap than the global default needs a policy its host registers. The two opt-in policies that once filled that role were removed because no consumer named them (see the Revision (2026-11-17)). Store's Sales module is the one consumer that registers its own:quote-ip(MMCA.Store/Source/Modules/Sales/MMCA.Store.Sales.API/QuoteRateLimiting.cs:26), a fixed one-minute window per client IP at 120 permits (:29,:32) withNoLimiterfor an unknown IP (:43-45), added to the host's limiter options byAddQuoteRateLimiting(:55-56) and named by the bag-quote action and the best-sellers action (MMCA.Store/Source/Modules/Sales/MMCA.Store.Sales.API/Controllers/OrderQuotesController.cs:36,.../Controllers/BestSellersController.cs:35). It is separate fromauth-ipso a busy checkout's repeated re-pricing cannot spend the bucket that guest-order placement also draws on (QuoteRateLimiting.cs:13-21). - The client IP these partitions key on is whatever the edge forwards, and that is trusted from any
proxy. Both IP-keyed decisions above (the
auth-ipwindow, and the global limiter's third-choice fallback key) readHttpContext.Connection.RemoteIpAddress, whichUseForwardedHeadershas already rewritten fromX-Forwarded-Forearlier in the same shared pipeline (UseCommonMiddlewarePipelineruns forwarded headers beforeUseRateLimiter). That middleware is configured to trust any proxy: the pipeline clears bothKnownProxiesandKnownIPNetworks, because cloud reverse proxies (Azure Container Apps, AWS ALB) front the services from internal addresses that are not in the default allow-lists, and an unlisted proxy means the headers are ignored and every request is attributed to the proxy instead. The decision is to take a caller-supplied IP as canonical rather than to run with no usable client IP at all. - Every per-IP partition keys on one client-address key, not the raw address.
ClientAddressKey.Forunmaps an IPv4-mapped address (::ffff:a.b.c.d) to plain IPv4 and masks an IPv6 address to its /64 prefix, so a subscriber rotating the low 64 bits of its address, or one client seen through two spellings on a dual-stack hop, stays one partition (MMCA.Common/Source/Build/RateLimiting/ClientAddressKey.cs:42-65, the text overload at:73-77, the reasoning at:13-18). It is one source file linked as an internal type intoMMCA.Common.API,MMCA.Common.Infrastructure,MMCA.Common.Aspire,MMCA.Common.UI.WebandMMCA.Common.Gateway, because the Gateway package references no MMCA project (ClientAddressKey.cs:25-28,MMCA.Common/Source/Hosting/MMCA.Common.Gateway/MMCA.Common.Gateway.csproj:23). The callers are theauth-ipwindow (MMCA.Common/Source/Presentation/MMCA.Common.API/Startup/WebApplicationBuilderExtensions.RateLimiting.cs:322), the anonymous-hub partition (:76), the global limiter's IP fallback (:166), themcpfallback (MMCA.Common/Source/Presentation/MMCA.Common.API/RateLimiting/McpCallerKey.cs:35), the Blazor host's edge limiter (MMCA.Common/Source/Presentation/MMCA.Common.UI.Web/Hardening/UiRateLimitingExtensions.cs:135), the gateway's per-IP and per-visitor windows (MMCA.Common/Source/Hosting/MMCA.Common.Aspire/Gateway/GatewayRateLimitingExtensions.cs:249,:258;MMCA.Common/Source/Hosting/MMCA.Common.Gateway/GatewaySettings.cs:276), and the registration cap inLoginProtectionService, which normalizes inside the service rather than where the controller reads the address, so the session record behind sign-in history keeps the real address (MMCA.Common/Source/Core/MMCA.Common.Infrastructure/Auth/LoginProtectionService.cs:257-267). The idempotency filter's anonymous subject is deliberately not this key: it keeps users' cached replays apart and is not a limiter, so masking it to /64 would let neighbours share each other's replays (ClientAddressKey.cs:21-22; the rawanon:{address}subject atMMCA.Common/Source/Presentation/MMCA.Common.API/Idempotency/IdempotencyFilter.cs:600-601, ADR-017).
Rationale
- Limit the traffic that is both attributable and expensive. An authenticated request is tied to a principal and usually drives the database; capping per-principal stops a single account from monopolizing a service without punishing the public read path.
- Do not punish shared-origin anonymous traffic. With Blazor Server fronting public browsing behind one IP, and public reads served from the output cache, an anonymous IP cap would throttle legitimate visitors at scale while barely protecting an already-cached backend.
- Right control per threat. Brute-force is an auth concern answered by a per-email lockout plus a per-IP cap on the anonymous credential endpoints that carry it (login, register, password reset, email confirmation, the machine-client token, OAuth discovery, passkey sign-in and sign-in links); general overload is a per-user request cap; infrastructure endpoints must never be throttled. A single global IP bucket conflates all three.
Trade-offs
- The global limiter only protects the authenticated surface. The anonymous surface is covered
endpoint by endpoint instead: the anonymous credential endpoints (login, register, password reset,
email confirmation, the machine-client token, OAuth discovery, passkey sign-in and sign-in links)
carry the
auth-iplimiter, with the login-protection service on top of it for login and register; anonymous hub paths are metered per IP by the global limiter itself; and public reads are served from the output cache. An uncached anonymous endpoint added later inherits none of that: it has no global cap and must opt into a named policy or its own control. - The per-IP cap keys on a header a caller can set. Trusting forwarded headers from any proxy is
what makes the IP usable at all behind a cloud load balancer, but it makes a spoofable input the
partition key of a security control. The exposure is bounded rather than absent:
ForwardLimitis left at its default of 1, so only the rightmostX-Forwarded-Forentry is consumed, and a proxy that appends the real client address wins for any traffic that actually traverses it. A caller that can reach a service without passing through that proxy can name its own IP and mint a freshauth-ipbucket per request, leaving the per-email lockout (ADR-029, not IP-keyed) as the control still standing in front of a spray. Containing this is a deployment concern, not a limiter one: either the gateway is the only reachable ingress, or the allow-lists carry the real proxy ranges. Neither is enforced in code: no source in Common, ADC or Store setsForwardLimitor populatesKnownProxies(the shared options only clear them,MMCA.Common/Source/Presentation/MMCA.Common.API/Startup/CommonForwardedHeaders.cs:49). The first is declared in infrastructure instead: both Bicep templates give every service container app internal-only ingress (external: false,MMCA.ADC/infra/main.bicep:2146,:2417,:2571,:2719;MMCA.Store/infra/main.bicep:1844,:2043,:2167) and expose only the gateway and the UI host (ADC:2914,:3077; Store:2338,:2467), so traffic from outside the environment reaches a service only through the gateway. A caller already inside the container-apps environment can still reach a service directly. - Per-user partitioning depends on the authenticated principal being populated when the limiter partitions the request, so the limiter's placement relative to authentication in the request pipeline is load-bearing: move it and the partition sees a different (or empty) principal.
- Defaults are deployment-agnostic. 300 requests/min/user is a coarse backstop, not a tuned SLO; a service with heavier legitimate per-user traffic must raise it, and a stricter endpoint needs a policy its host registers, since the framework ships none for that purpose.
- In-process counters, where a limiter is not distributed. A local limiter's state is
per-instance, so across N replicas its effective ceiling is roughly N times the configured limit.
This holds for
auth-ip(always in-memory,allowDistributed: falseatMMCA.Common/Source/Presentation/MMCA.Common.API/Startup/WebApplicationBuilderExtensions.RateLimiting.cs:354), for the gateway limiters, and for the global, hub andmcpwindows (allowDistributed: trueat:196,:101,:224) in any host that leavesDistributedunset (see the Revision (2026-08-18)). ADC production setsRateLimiting__Distributed=trueon all four services (MMCA.ADC/infra/main.bicep:2226,:2482,:2622,:2788). The AppHost does the same only in its opt-in multi-replica run: it readsMmcaReplicas.FromEnvironment("ADC_REPLICAS")and passesdistributedRateLimiting: truefor the four services andfalsefor the gateway (MMCA.ADC/Source/Hosting/MMCA.ADC.AppHost/Program.cs:446-451), and the framework helper floors the count at 1, changes nothing at 1 or less, and setsDistributedonly when that flag is true (MMCA.Common/Source/Hosting/MMCA.Common.Aspire.Hosting/MmcaReplicas.cs:43,:67-76). So there those three windows share one Redis budget across replicas and onlyauth-ipand the gateway limiters scale with replica count (MMCA.ADC/infra/main.bicep:2220-2225). Store sets noDistributedvalue, so every Store limiter stays per-instance.
Revision (2026-08-18)
The layering above is unchanged: the global limiter is still authenticated-only, infrastructure and
anonymous traffic are still exempt, auth-ip still covers login and register by default, and
FixedPolicy / UserPolicy are still opt-in with nothing applying them. Three things below it
changed.
- The limits are now a validated settings section.
RateLimitingSettings(MMCA.Common/Source/Presentation/MMCA.Common.API/RateLimiting/RateLimitingSettings.cs:21) binds the"RateLimiting"section (:24) atMMCA.Common/Source/Presentation/MMCA.Common.API/Startup/WebApplicationBuilderExtensions.cs:307, falling back to a default instance when the section is absent, so an unconfigured host keeps exactly the behavior this record describes. Every figure the Decision quotes now has a named home and a[Range]:GlobalPermitLimit300 (:38-40),AuthIpPermitLimit30 (:46-47),PerUserPermitLimit30 forUserPolicy(:34-36), andPermitLimit100 plusQueueLimit2 forFixedPolicy(:26-32). - A sliding window is selectable.
Algorithm(:53) takesRateLimitAlgorithm.FixedWindow(the default) orSlidingWindow(.../RateLimiting/RateLimitAlgorithm.cs:15,22), withSegmentsPerWindowdefaulting to 4 (:61-62,[Range(1, 60)], ignored underFixedWindow). The window itself stays one minute under both algorithms (RateLimitAlgorithm.cs:5-6), so this is a smoothing choice, not a new cap: a fixed window lets a caller spend a full minute's budget in the last second of one window and again in the first second of the next, and the segmented window removes that doubling at the cost of holding per-segment state. - The global and
UserPolicypartitions can be Redis-backed.Distributed(:72, defaultfalse) swaps inRedisFixedWindowRateLimiter(.../RateLimiting/RedisFixedWindowRateLimiter.cs:37), which keys onrl:{partitionKey}:{unixMinute}(:129-130), performs aStringIncrementAsync(:135), and sets a 65-second TTL only on the increment that created the key (:137-143, the 5 seconds of slack being deliberate clock skew,:139-141), admitting the request when the returned count is within the permit limit (:145). Three partitions opt in: the global limiter (WebApplicationBuilderExtensions.cs:79-104, Redis scope"global"at:99),UserPolicy(:114-128, scope"user"at:123), and, since the 2026-09-07 revision below, the anonymous hub partition (AnonymousPartition, scope"hub"atMMCA.Common/Source/Presentation/MMCA.Common.API/Startup/WebApplicationBuilderExtensions.cs:96).
auth-ip deliberately stays in-memory (allowDistributed: false,
WebApplicationBuilderExtensions.cs:234, rationale at :143-147), as does FixedPolicy
(:346-353). The per-IP cap on the anonymous authentication endpoints is a coarse brute-force
backstop sitting in front of a control that is already global and stateful, the ADR-029 per-email
lockout; making it distributed would put a Redis round trip on the login path to tighten a limit whose
per-replica multiplication is already accounted for in its generous default of 30.
The distributed limiter fails open. Any Redis fault other than cancellation is caught and the
lease is granted (:147-155), with a warning emitted at most once per window through an
Interlocked.Exchange guard on a static field (:149-151, :44). That is the same posture the
global limiter already takes for a request with no attributable IP: a rate limiter is a backstop, and
a broken backstop must not become an outage. Two consequences are worth naming. The increment and the
comparison are not transactional (:26-29), so genuinely concurrent requests can overshoot the limit
slightly, which is accepted for a coarse cap. And setting Distributed = true in a host with no
IConnectionMultiplexer registered silently degrades to the in-memory limiter rather than failing
startup (:150-167, documented at RateLimitingSettings.cs:64-71), so this setting sits outside the
ADR-070 fail-fast contract and a misconfiguration looks exactly like success.
The "In-process counters" trade-off above is therefore narrowed rather than removed: the effective
ceiling is still roughly N times the configured limit across N replicas for auth-ip and
FixedPolicy, and for the global and per-user partitions in any host that has not set Distributed
or has no multiplexer. Every other trade-off in this record stands unchanged, including the
forwarded-header trust posture, which the Redis partition key inherits verbatim.
Revision (2026-09-07)
The layering is unchanged: the global limiter is still authenticated-only, login and register still
carry auth-ip, and infrastructure paths are still exempt. Four things below it moved, all from the
2026-09-07 security review.
- The gRPC exemption no longer trusts a request header (SEC-Common-44).
IsRateLimitBypassed(MMCA.Common/Source/Presentation/MMCA.Common.API/Startup/WebApplicationBuilderExtensions.cs:75, applied at:171) decides on gRPC endpoint metadata, which routing produces from the server's ownMapGrpcServiceregistrations, so stampingContent-Type: application/grpcon an ordinary request no longer switches off the per-user cap. The HTTPS-redirect skip that shared the old test keys on the negotiated protocol instead (MiddlewarePipelineBuilder.IsCleartextHttp2,MMCA.Common/Source/Presentation/MMCA.Common.API/Startup/Pipeline/MiddlewarePipelineBuilder.cs:362, branched at:98). - Anonymous hub traffic is metered rather than exempt (SEC-ADC-25).
IsAnonymousHubRequest(WebApplicationBuilderExtensions.cs:111) matches the request path againstRateLimitingSettings.HubPathPrefixes(default["/hubs"],MMCA.Common/Source/Presentation/MMCA.Common.API/RateLimiting/RateLimitingSettings.cs:91) and partitions those requests per client IP atAnonymousHubPermitLimit(default 60 per minute,:99, applied atWebApplicationBuilderExtensions.cs:92-97). This is the one hole the "exempt anonymous traffic" rule left that no edge control reliably covers: a hub path is a long-lived upgrade an edge limiter is usually configured to pass through, and the traffic is anonymous until the connection is established. - A trusted internal caller can be exempted at the gateway.
GatewayRateLimitingSettings.TrustedCallerSecret(:151) andTrustedCallerHeaderName(defaultX-Internal-Caller-Key,:123) (MMCA.Common/Source/Hosting/MMCA.Common.Aspire/Gateway/GatewayRateLimitingSettings.cs) generalize the synthetic-traffic bypass that already sat beside them (:91,:115). It is off unless the secret is configured, the header is single-valued, and the comparison is constant time (CryptographicOperations.FixedTimeEquals,MMCA.Common/Source/Hosting/MMCA.Common.Aspire/Gateway/GatewayRateLimitingExtensions.cs:162, wired at:138-139). It exists for the shared-origin problem this record already names: a server-rendered UI host's own back-end calls, token refresh above all, otherwise collapse into one client-IP partition and throttle every visitor together. - ADC scopes its tighter gateway policy to the credential-submission routes. The gateway's
auth-tightpolicy (MMCA.ADC/Source/Hosts/MMCA.ADC.Gateway/appsettings.json:63) is attached toidentity-auth-login(:88-94, the policy at:93) andidentity-auth-register(:95-101, the policy at:100) and to nothing else, so/Auth/refreshkeeps the exemption this record requires for Blazor Server circuits, whose refreshes all leave from the UI host's address.
Revision (2026-09-10)
Both gateways now scope auth-tight the same way, and the trusted-caller exemption's client half
ships in the framework. Two items, both landed.
- Store's gateway splits the credential routes out of the
/Authcatch-all. Itsauth-tightpolicy (MMCA.Store/Source/Hosts/MMCA.Store.Gateway/appsettings.json:37, the block at:36-43) is attached toidentity-auth-login(:78-84, the policy at:83) andidentity-auth-register(:85-91, the policy at:90), and the remainingidentity-authroute matching/Auth/{**catch-all}(:94-98) carries noRateLimiterPolicyat all, so refresh, logout, forgot-and-reset and the OAuth callbacks sit on the edge global limiter alone. That is the same three-route shape ADC has, and it is what item 4 above requires of any Blazor Server host: a circuit's refreshes all leave from the UI host's single address, so a per-IP cap on/Auththrottles every visitor together. The pin moved with it:CredentialRoutes_CarryTheTightRateLimiterPolicy(MMCA.Store/Tests/Hosts/MMCA.Store.Gateway.Tests/MmcaGatewayTests.cs:150) asserts both directions, that every credential route carries the policy (:161-165) and that the set of routes carrying any policy is exactly that pair (:169-173), so re-attaching it to the catch-all fails the build. - The trusted-caller client half is framework code, not per-app code. The header a UI host sends
so its own back-end calls take the exempt partition is registered by
AddTrustedCallerHeader, shipped inMMCA.Common.UI.Web1.191.0 (MMCA.Common/Source/Presentation/MMCA.Common.UI.Web/DependencyInjection.cs:87, in theextension(IServiceCollection services)block at:20). Both UI hosts call it and nothing else does (MMCA.ADC/Source/Hosts/UI/MMCA.ADC.UI.Web/Program.cs:117,MMCA.Store/Source/Hosts/UI/MMCA.Store.UI.Web/Program.cs:141). The client reads the sameGatewayRateLimitingsection the gateway side already binds (MMCA.Common/Source/Hosting/MMCA.Common.Aspire/Gateway/GatewayRateLimitingSettings.cs:47), which is now the one section name in both repos: Store's UI host declaresGatewayRateLimiting:TrustedCallerHeaderNameatMMCA.Store/Source/Hosts/UI/MMCA.Store.UI.Web/appsettings.json:32-34and ADC's gateway declares the section atMMCA.ADC/Source/Hosts/MMCA.ADC.Gateway/appsettings.json:21-33(the header name at:32), with the secret injected asGatewayRateLimiting__TrustedCallerSecretby each template (MMCA.Store/infra/main.bicep:1889and:2006,MMCA.ADC/infra/main.bicep:2223and:2363). One name on both sides of the boundary is the point: a client sending under one key while the gateway reads another fails open silently, as a plain throttled caller.
Revision (2026-10-01)
No decision or rationale changed. Two current-state statements in the Decision were corrected. The
ADC Conference output-cache list now reads as a sample of a larger per-aggregate set
(MMCA.ADC/Source/Services/MMCA.ADC.Conference.Service/Program.cs:266-295) rather than as the
complete set. The auth-ip no-IP rule (NoLimiter,
MMCA.Common/Source/Presentation/MMCA.Common.API/Startup/WebApplicationBuilderExtensions.RateLimiting.cs:284-285)
no longer claims to mirror the global limiter, because the global limiter does not fail open for
unattributable traffic: an authenticated request with no subject, name or IP shares the
"authenticated" bucket (:149-152) and an anonymous hub request with no IP shares the
"anonymous-hub" bucket (:62); only anonymous non-hub traffic gets NoLimiter (:68), and that
is the anonymous exemption, not a no-IP rule. The rate-limiting registration now lives in the
partial WebApplicationBuilderExtensions.RateLimiting.cs, so the WebApplicationBuilderExtensions.cs
anchors in the Revisions above are historical and are not rewritten.
Revision (2026-10-06)
Every ADC service binds the RateLimiting section. ADC's Identity and Notification services now
call the configuration overload, AddCommonRateLimiting(builder.Configuration)
(MMCA.ADC/Source/Services/MMCA.ADC.Identity.Service/Program.cs:165,
MMCA.ADC/Source/Services/MMCA.ADC.Notification.Service/Program.cs:144), so their declared limits bind
through RateLimitingSettings instead of being ignored by the int overload. The Bicep key moved to the
bound property name, RateLimiting__AuthIpPermitLimit (MMCA.ADC/infra/main.bicep:1836, rationale at
:1831). The gateway auth-tight anchors in item 4 and in Revision (2026-09-10) point at the current
lines.
- The email-confirmation
auth-ipdecoration belongs to the framework, not the apps. Decision item 3 said each app'sEmailConfirmationControllerapplied the policy to the two actions the framework bases did not own.EmailConfirmationControllerBasenow carries the attribute on both (MMCA.Common/Source/Presentation/MMCA.Common.API/Controllers/EmailConfirmationControllerBase.cs:81,:109) and the Store and ADC controllers are subclasses with no attribute of their own, so the Decision now counts six framework-decorated actions. - Current locations of facts recorded in the older Revisions (those sections keep their original
anchors). In
MMCA.Common/Source/Presentation/MMCA.Common.API/Startup/WebApplicationBuilderExtensions.RateLimiting.cs:IsRateLimitBypassed:46,AnonymousPartition:62(the"anonymous-hub"key:66, the anonymousNoLimiter:72),IsAnonymousHubRequest:82, the__infraNoLimiter:145, the global partition key chain ending in"authenticated":153-156,AuthIpRateLimitPartition:305(__unknown-ipNoLimiter:310,allowDistributed: false:318), andFixedPolicyallowDistributed: false:414. InRedisFixedWindowRateLimiter.cs:StringIncrementAsync:137, the 65-secondKeyExpireAsync:144, the fail-opencatch:149and itsInterlocked.Exchangewarn-once guard:151.MiddlewarePipelineBuilder.IsCleartextHttp2is defined atMMCA.Common/Source/Presentation/MMCA.Common.API/Startup/Pipeline/MiddlewarePipelineBuilder.cs:350and used at:86.GatewayRateLimitingSettings.cs:SectionName:51,TrustedCallerHeaderName:126,TrustedCallerSecret:154;GatewayRateLimitingExtensions.cs:FixedTimeEquals:172, wired at:148-149.AddTrustedCallerHeaderis atMMCA.Common/Source/Presentation/MMCA.Common.UI.Web/DependencyInjection.cs:121, called fromMMCA.ADC/Source/Hosts/UI/MMCA.ADC.UI.Web/Program.cs:136andMMCA.Store/Source/Hosts/UI/MMCA.Store.UI.Web/Program.cs:129; Store's UI section is atMMCA.Store/Source/Hosts/UI/MMCA.Store.UI.Web/appsettings.json:35-36. The trusted-caller secret is injected atMMCA.Store/infra/main.bicep:1959and:2084andMMCA.ADC/infra/main.bicep:2444and:2602. - Anchors in the live sections (the Conference output-cache range and the unattributable-bucket anchors in Decision item 3) were re-verified against current source.
Revision (2026-10-07)
Re-verified against current source. The layering, every default, the auth-ip surface, the
fail-open posture and both gateways' auth-tight scoping are unchanged. One storage detail of the
distributed limiter moved, and the anchors that drifted since the 2026-10-06 audit are re-pointed.
- The Redis partition key is namespaced per application (SEC-Common-53, shipped in MMCA.Common
v1.232.0). The framework builds
each
RedisFixedWindowRateLimiterwith the partition key{namespace}:{scope}:{partition}(MMCA.Common/Source/Presentation/MMCA.Common.API/Startup/WebApplicationBuilderExtensions.RateLimiting.cs:254, rationale at:247-249), where the namespace isCache:KeyPrefixwith its trailing colon trimmed, orApplicationNamespace.Resolvewhen no prefix is set (:199-205). That matches how the distributed cache resolves its own prefix: a configuredCache:KeyPrefixas is, else the application namespace plus:(MMCA.Common/Source/Core/MMCA.Common.Infrastructure/Caching/CacheKeyPrefix.cs:73-88). The limiter still prefixesrl:and appends the Unix minute (MMCA.Common/Source/Presentation/MMCA.Common.API/RateLimiting/RedisFixedWindowRateLimiter.cs:132, documented at:24-26), so the stored key isrl:{namespace}:{scope}:{partition}:{unixMinute}. By default, two MMCA applications pointed at one Redis therefore do not share a counter. Two hosts that set the sameCache:KeyPrefixorApplication:Namespaceshare a namespace on purpose (MMCA.Common/Source/Core/MMCA.Common.Infrastructure/Caching/CacheKeyPrefix.cs:37-40,MMCA.Common/Source/Core/MMCA.Common.Infrastructure/Configuration/ApplicationNamespace.cs:22-25), and a host with no application name falls back toapp(ApplicationNamespace.cs:34,:67). Therl:keyspace the Related section names still holds. - The Conference output-cache range drifted after the 2026-10-06 audit. The range was correct
when that audit re-verified it; MMCA.ADC #255 later moved it by two lines through comment edits
higher in the file. The
AddPublicEndpointPolicycalls now run fromConferencePublicCache(MMCA.ADC/Source/Services/MMCA.ADC.Conference.Service/Program.cs:269) toBookmarkCountsCache(:300), and the four sampled names are all present (EventsCache:270,RoomsCache:278,CategoriesCache:279,QuestionsCache:280); Decision item 2 now cites:269-300. The unattributable-bucket anchors in Decision item 3 were and remain correct ("anonymous-hub":66,"authenticated":156,__unknown-ipNoLimiter:310inWebApplicationBuilderExtensions.RateLimiting.cs). - Anchors re-verified against current source:
AddTrustedCallerHeaderis called fromMMCA.ADC/Source/Hosts/UI/MMCA.ADC.UI.Web/Program.cs:137(Store:129and the definition atMMCA.Common/Source/Presentation/MMCA.Common.UI.Web/DependencyInjection.cs:121unchanged).CredentialRoutes_CarryTheTightRateLimiterPolicyis declared atMMCA.Store/Tests/Hosts/MMCA.Store.Gateway.Tests/MmcaGatewayTests.cs:144, with the per-route assertion loop at:155-161and the exact-setBeEquivalentToassertion at:163-168, still pinning both directions.RateLimiting__AuthIpPermitLimitis atMMCA.ADC/infra/main.bicep:1868(value'300'inside theconferenceModeblock, rationale at:1863-1865), and the ADCGatewayRateLimiting__TrustedCallerSecretinjections are at:2491and:2650(StoreMMCA.Store/infra/main.bicep:1959and:2084unchanged).
Revision (2026-10-19)
Store's services bind the RateLimiting section as well. Catalog, Sales and Identity now call
AddCommonRateLimiting(builder.Configuration)
(MMCA.Store/Source/Services/MMCA.Store.Catalog.Service/Program.cs:141,
MMCA.Store/Source/Services/MMCA.Store.Sales.Service/Program.cs:149,
MMCA.Store/Source/Services/MMCA.Store.Identity.Service/Program.cs:136) in place of the
parameterless int overload, matching ADC's four services (Conference :221, Engagement :151,
Identity :165, Notification :144). Store declares no RateLimiting section in its service
configuration today, so the bound settings fall back to their defaults and its limits are
unchanged; what changes is that per-environment tuning and the distributed Redis limiter
(Revision 2026-08-18) are reachable in Store by configuration alone.
Revision (2026-10-21)
Re-verified against current source. The layering, every default, the auth-ip surface, the
fail-open posture, the 65-second TTL and both gateways' auth-tight scoping are unchanged. One
storage detail of the distributed limiter moved, one trade-off gained its infrastructure context,
and the anchors that drifted since the 2026-10-19 revision are re-pointed.
- Increment and expiry are one atomic Lua script.
RedisFixedWindowRateLimiterno longer issues aStringIncrementAsyncfollowed by a separateKeyExpireAsync(the shape Revision 2026-08-18 records).IncrementScript(MMCA.Common/Source/Presentation/MMCA.Common.API/RateLimiting/RedisFixedWindowRateLimiter.cs:50-53) runsINCRBYand thenEXPIREonly when the returned count is no greater than the permits requested, which is the increment that created the key, withKeyTtlSeconds65 (:60); it is sent throughScriptEvaluateAsync(:166), and the type documents why: no failure between the two commands can leave a key with no expiry (:29-30). The increment and the permit comparison (:172) are still not transactional, so the slight concurrent overshoot accepted in Revision 2026-08-18 stands (:31-33). The fail-opencatch(:174) and its warn-onceInterlocked.Exchangeguard (:176, on the static field at:67) are unchanged. The Related section now names theINCRBYscript rather than a rawINCR. - The forwarded-header trade-off records the declared ingress. Its closing statement said
neither containment option was enforced. That holds for code (nothing in Common, ADC or Store sets
ForwardLimitor populatesKnownProxies,MMCA.Common/Source/Presentation/MMCA.Common.API/Startup/CommonForwardedHeaders.cs:49, and the gateway copy only clears too,MMCA.Common/Source/Hosting/MMCA.Common.Gateway/ForwardedHeadersExtensions.cs:62), but both Bicep templates declare every service's ingress internal-only and expose only the gateway and UI host, so the trade-off now says so and names the residual in-environment path. - Anchors re-verified against current source: the Conference output-cache policies run from
ConferencePublicCache(MMCA.ADC/Source/Services/MMCA.ADC.Conference.Service/Program.cs:270) toBookmarkCountsCache(:301), withEventsCache:271,RoomsCache:279,CategoriesCache:280andQuestionsCache:281, and Decision item 2 now cites:270-301. ADC Identity callsAddCommonRateLimiting(builder.Configuration)atMMCA.ADC/Source/Services/MMCA.ADC.Identity.Service/Program.cs:166(Conference:221, Engagement:151, Notification:144, and Store's three services unchanged). The Redis key is built atRedisFixedWindowRateLimiter.cs:161(documented at:24-28). ADC's gateway attachesauth-tight(MMCA.ADC/Source/Hosts/MMCA.ADC.Gateway/appsettings.json:63) toidentity-auth-login(:90-96, the policy at:95) andidentity-auth-register(:97-103, the policy at:102), and theidentity-authcatch-all (:106) carries none, so the Revision (2026-09-07) item 4 anchors are historical.RateLimiting__AuthIpPermitLimitis atMMCA.ADC/infra/main.bicep:2024(value'300'inside theconferenceModeblock, rationale at:2016-2021); the ADCGatewayRateLimiting__TrustedCallerSecretinjections are at:2647and:2806, and Store's atMMCA.Store/infra/main.bicep:2053and:2178.
Revision (2026-10-26)
Re-verified against current source. The layering, every default, the auth-ip surface, the
fail-open posture, the atomic INCRBY script and its 65-second TTL, the application-namespaced Redis
key, the declared internal-only service ingress and both gateways' auth-tight scoping are
unchanged. No behavior moved; the anchors that drifted since the 2026-10-21 revision are re-pointed,
and the Related section gains the record that owns the application namespace.
- Related names ADR-135. The Redis partition key's namespace (Revision 2026-10-07) is the application namespace that ADR-135 records as the one isolation rule for shared infrastructure keyspaces, so the Related section now points there for that decision rather than leaving it implied by this record and ADR-026.
- The unattributable-bucket anchors in Decision item 3 moved. Revision 2026-10-07 recorded them
as unchanged; they have since moved with the file. In
MMCA.Common/Source/Presentation/MMCA.Common.API/Startup/WebApplicationBuilderExtensions.RateLimiting.csthe"anonymous-hub"fallback key is at:87, the"authenticated"fallback at:177, and theauth-ip__unknown-ipNoLimiterbranch at:330-331(inside the settings overload ofAuthIpRateLimitPartition,:326); Decision item 3 now cites those lines. - Anchors re-verified against current source. In
WebApplicationBuilderExtensions.RateLimiting.cs:IsRateLimitBypassed:67,AnonymousPartition:83(the anonymousNoLimiter:93),IsAnonymousHubRequest:103, the__infraNoLimiter:166,auth-ipallowDistributed: false:339, andFixedPolicyallowDistributed: false:439. The Redis partition key{namespace}:{scope}:{partition}is built at:275(rationale:268-270), the namespace is resolved byRateLimitKeyNamespace(:220-226, trailing colon trimmed at:225), and with no multiplexer registered the factory falls through to the in-memory limiters (:263,:280-283). InMMCA.Common/Source/Presentation/MMCA.Common.API/RateLimiting/RedisFixedWindowRateLimiter.cs:IncrementScript:50-53,KeyTtlSeconds:60, the static_lastLoggedFailureWindow:67, therl:key built at:164,ScriptEvaluateAsync:169, the permit comparison:175, the fail-opencatch:179and itsInterlocked.Exchangeguard:181.MiddlewarePipelineBuilder.IsCleartextHttp2is defined atMMCA.Common/Source/Presentation/MMCA.Common.API/Startup/Pipeline/MiddlewarePipelineBuilder.cs:349and used at:85.GatewayRateLimitingSettings.cskeepsSectionName:51,TrustedCallerHeaderName:126andTrustedCallerSecret:154; inMMCA.Common/Source/Hosting/MMCA.Common.Aspire/Gateway/GatewayRateLimitingExtensions.cstheFixedTimeEqualscomparison is at:195inside the sharedPresentsSecrethelper (:179), whichIsTrustedInternalCaller(:164) calls with the trusted-caller settings (:171-172), applied at:208(the last term of theIsExemptFromLimitersOR chain,:205-208) and:225.AddTrustedCallerHeader(MMCA.Common/Source/Presentation/MMCA.Common.UI.Web/DependencyInjection.cs:121) is called fromMMCA.ADC/Source/Hosts/UI/MMCA.ADC.UI.Web/Program.cs:143andMMCA.Store/Source/Hosts/UI/MMCA.Store.UI.Web/Program.cs:135and from no other host (outside those two, only MMCA.Common's own tests call it). Every service callsAddCommonRateLimiting(builder.Configuration): ADC ConferenceMMCA.ADC/Source/Services/MMCA.ADC.Conference.Service/Program.cs:227, Engagement:157, Identity:172, Notification:150; Store CatalogMMCA.Store/Source/Services/MMCA.Store.Catalog.Service/Program.cs:147, Sales:155, Identity:142. The Conference output-cache policies run fromConferencePublicCache(MMCA.ADC/Source/Services/MMCA.ADC.Conference.Service/Program.cs:276) toBookmarkCountsCache(:307), withEventsCache:277,RoomsCache:285,CategoriesCache:286andQuestionsCache:287, and Decision item 2 now cites:276-307. InMMCA.ADC/infra/main.bicepRateLimiting__Distributedis set at:1952,:2193,:2330and:2484(rationale:1946-1951; the AppHost atMMCA.ADC/Source/Hosting/MMCA.ADC.AppHost/Program.cs:477, only whenADC_REPLICASis greater than 1,:459-464),RateLimiting__AuthIpPermitLimit'300'at:2060(rationale:2052-2057), service ingress is internal at:1876,:2129,:2282and:2417and the gateway and UI host are external at:2607and:2770, and the trusted-caller secret is injected at:2683and:2842. InMMCA.Store/infra/main.bicepservice ingress is internal at:1529,:1711and:1835, the gateway and UI host are external at:1987and:2116, the trusted-caller secret is injected at:2059and:2184, and no service-sideRateLimiting__key is set. The Trade-offs anchors now cite these lines.
Revision (2026-10-28)
Re-verified against current source. The layering, every default, the auth-ip surface, the
declared internal-only service ingress (only the gateway and the UI host are external in both
templates), ADC's Distributed=true on all four services, Store's absence of any service-side
RateLimiting__ key, and the two-host scope of AddTrustedCallerHeader are unchanged. No behavior
moved; only anchors drifted since the 2026-10-26 revision, and the Trade-offs section now cites the
lines below.
- Anchors re-verified against current source. In
MMCA.ADC/infra/main.bicepservice ingress is internal at:1873,:2126,:2279and:2414(theexternal: falseat:2425is Notification's internal gRPC port mapping), the gateway and UI host are external at:2604and:2767,RateLimiting__Distributedis set at:1949,:2190,:2327and:2481(rationale:1943-1948),RateLimiting__AuthIpPermitLimit'300'at:2057(rationale:2049-2054), and the trusted-caller secret is injected at:2680and:2839. InMMCA.Store/infra/main.bicepservice ingress is internal at:1530,:1712and:1836(theexternal: falseat:1849is Sales' internal gRPC port mapping), the gateway and UI host are external at:1988and:2117, and the trusted-caller secret is injected at:2060and:2185; the only rate-limiting keys areGatewayRateLimiting__*.AddTrustedCallerHeader(MMCA.Common/Source/Presentation/MMCA.Common.UI.Web/DependencyInjection.cs:121) is called fromMMCA.ADC/Source/Hosts/UI/MMCA.ADC.UI.Web/Program.cs:144andMMCA.Store/Source/Hosts/UI/MMCA.Store.UI.Web/Program.cs:136. ADC Identity callsAddCommonRateLimiting(builder.Configuration)atMMCA.ADC/Source/Services/MMCA.ADC.Identity.Service/Program.cs:173. Store's UIGatewayRateLimitingsection is atMMCA.Store/Source/Hosts/UI/MMCA.Store.UI.Web/appsettings.json:47, withTrustedCallerHeaderNameat:48.
Revision (2026-11-17)
The layering is unchanged: the global limiter is still authenticated-only, infrastructure and
anonymous traffic outside the hub paths are still exempt, and auth-ip still covers the anonymous
credential endpoints by default. What changed is the set of named policies, removed in the
API-projects drift review (MMCA.Common v1.300.0) because no consumer named them.
FixedPolicyandUserPolicyare gone.AddCommonRateLimiting(RateLimitingSettings)registers the global limiter and themcppolicy (MMCA.Common/Source/Presentation/MMCA.Common.API/Startup/WebApplicationBuilderExtensions.RateLimiting.cs:434,:439) plusauth-ip(:449); theUserPolicyRateLimitPartitionselector went with them. The int overload is nowAddCommonRateLimiting(int globalPermitLimit = 300, int authIpPermitLimit = 30)(:385).- Their settings are gone.
RateLimitingSettingsno longer carriesPermitLimit,QueueLimitorPerUserPermitLimit; it keepsGlobalPermitLimit300 (MMCA.Common/Source/Presentation/MMCA.Common.API/RateLimiting/RateLimitingSettings.cs:28),AuthIpPermitLimit30 (:35),McpPermitLimit60 (:43),Algorithm(:49),SegmentsPerWindow4 (:58),Distributed(:68) andAnonymousHubPermitLimit60 (:95). Distributednow names the windows it actually reaches. It moves the global limiter, the anonymous hub partition and themcppolicy ontoRedisFixedWindowRateLimiter(RateLimitingSettings.cs:60-68;MMCA.Common/Source/Presentation/MMCA.Common.API/RateLimiting/RedisFixedWindowRateLimiter.cs:9-14);auth-ipstays in memory (WebApplicationBuilderExtensions.RateLimiting.cs:353).
Decision item 4 and the Trade-offs now describe that set. The FixedPolicy, UserPolicy,
PermitLimit, QueueLimit and PerUserPermitLimit statements and anchors in the earlier revisions
(2026-08-18 items 1 and 3 and its in-memory paragraphs, and the later anchor lists) are history and
are superseded by this revision.
Revision (2026-11-23)
Re-verified against current source. The layering, every default, the authenticated-only global
limiter, the fail-open distributed windows, the in-memory auth-ip, the declared internal-only
service ingress in both templates, ADC's Distributed=true on its four services and Store's absence
of any service-side RateLimiting__ key are unchanged. What moved is the breadth of the auth-ip
surface, one consumer-registered policy, the path by which hosts reach the framework registrations,
one ADC gateway route, and the anchors.
auth-ipcovers twelve framework actions, not six. The original six stand (MMCA.Common/Source/Presentation/MMCA.Common.API/Controllers/AuthControllerBase.cs:78,:103;PasswordResetAuthControllerBase.cs:78,:102;EmailConfirmationControllerBase.cs:81,:109;RefreshAsyncstill carries none). Six more carry the same attribute: the machine-client token (Controllers/MachineClients/MachineTokenControllerBase.cs:48), OAuthdiscover(Controllers/OAuthControllerBase.cs:176), passkeysignin/optionsandsignin(Controllers/Passkeys/PasskeysControllerBase.cs:232,:257) andsign-in-linkandsign-in-link/redeem(Controllers/SignInLinks/SignInLinkControllerBase.cs:83,:111). Store names the policy on two guest-order actions of its own (MMCA.Store/Source/Modules/Sales/MMCA.Store.Sales.API/Controllers/GuestOrdersController.cs:58,:208). The OAuthexchangePOST (Controllers/OAuthControllerBase.cs:289-293), thecompletecallback (:204-205) and the provider challenge actions (:115-155) are anonymous but carry no rate-limiting attribute. Decision item 3, the Rationale and the Trade-offs now list that surface.- One consumer registers its own named policy. Store's
quote-ip(MMCA.Store/Source/Modules/Sales/MMCA.Store.Sales.API/QuoteRateLimiting.cs:26, added at:56, 120 per IP per minute at:29) is applied atControllers/OrderQuotesController.cs:36andControllers/BestSellersController.cs:35. It is the shape Decision item 4 prescribes (a tighter or differently sized cap is a policy the host registers), so item 4 now records it. - No ADC or Store service calls
AddCommonRateLimitingdirectly. The composed service host does it:AddMmcaServiceHost(MMCA.Common/Source/Hosting/MMCA.Common.ServiceHost/ServiceHostBuilderExtensions.cs:63) calls the configuration overload at:108, and every ADC and Store service callsAddMmcaServiceHost(ADC ConferenceMMCA.ADC/Source/Services/MMCA.ADC.Conference.Service/Program.cs:82, Engagement:58, Identity:82, Notification:58; Store CatalogMMCA.Store/Source/Services/MMCA.Store.Catalog.Service/Program.cs:32, Identity:37, Sales:51). Helpdesk's single web host, which is not a composed service host, still calls the int overload itself (MMCA.Helpdesk/Source/Hosts/MMCA.Helpdesk.Web/Program.cs:37). The binding the 2026-10-06 and 2026-10-19 revisions record still holds; the per-Program.cscall sites they and the 2026-10-21, 2026-10-26 and 2026-10-28 revisions cite for ADC and Store are history. - No UI host calls
AddTrustedCallerHeaderdirectly.AddMmcaBlazorWebHost(MMCA.Common/Source/Presentation/MMCA.Common.UI.Web/Hosting/BlazorWebHostExtensions.cs:75) calls it at:126(definition unchanged atMMCA.Common/Source/Presentation/MMCA.Common.UI.Web/DependencyInjection.cs:121), and ADC's and Store's UI hosts callAddMmcaBlazorWebHost(MMCA.ADC/Source/Hosts/UI/MMCA.ADC.UI.Web/Program.cs:26,MMCA.Store/Source/Hosts/UI/MMCA.Store.UI.Web/Program.cs:30). It is still two hosts in practice, through framework composition rather than a per-app call. - ADC's gateway attaches
auth-tightto a third route.identity-auth-token(/Auth/token, the ADR-140 machine-client token, a credential submission like login and register) carries it (MMCA.ADC/Source/Hosts/MMCA.ADC.Gateway/appsettings.json:106-112, the policy at:111), besideidentity-auth-login(:90-96,:95) andidentity-auth-register(:97-103,:102). Theidentity-authcatch-all (:115-119) still carries none, so/Auth/refreshkeeps its exemption; passkey sign-in rides that catch-all and relies on the service-sideauth-ip(:147-149). The "two credential routes and nothing else" statements in the 2026-09-07, 2026-09-10 and 2026-10-21 revisions describe ADC as it was then. Store's gateway keeps the two-route set. - The AppHost's multi-replica switch is framework code. The
ADC_REPLICASgate and theRateLimiting__Distributed=trueenvironment value now live inMMCA.Common/Source/Hosting/MMCA.Common.Aspire.Hosting/MmcaReplicas.cs(:43,:67-76), called fromMMCA.ADC/Source/Hosting/MMCA.ADC.AppHost/Program.cs:446-451; the Trade-offs cite them. - Anchors re-verified against current source. In
MMCA.Common/Source/Presentation/MMCA.Common.API/Startup/WebApplicationBuilderExtensions.RateLimiting.cs:RateLimitPolicyMcp:57,IsRateLimitBypassed:76, the"anonymous-hub"key:96and itsallowDistributed: true:101,IsAnonymousHubRequest:112,"authenticated":187, the globalallowDistributed: true:196,McpRateLimitPartition:209-225(allowDistributed: true:224),RateLimitKeyNamespace:233, the Redis key{namespace}:{scope}:{partition}:288, theauth-ip__unknown-ipNoLimiter:345-346andallowDistributed: false:354, the int overload:388,GlobalLimiter:437, themcpAddPolicy:442and theauth-ipAddPolicy:452-453.RequireRateLimiting(RateLimitPolicyMcp)is atMMCA.Common/Source/Presentation/MMCA.Common.Mcp/McpHostingExtensions.cs:136, andMcpPermitLimitatRateLimitingSettings.cs:42-43.MiddlewarePipelineBuilder.IsCleartextHttp2is defined atMMCA.Common/Source/Presentation/MMCA.Common.API/Startup/Pipeline/MiddlewarePipelineBuilder.cs:358and used at:85, withUseForwardedHeaders:68,UseAuthentication:104andUseRateLimiter:120. InMMCA.Common/Source/Hosting/MMCA.Common.Aspire/Gateway/GatewayRateLimitingExtensions.cs:IsTrustedInternalCaller:181,PresentsSecret:196,FixedTimeEquals:212,IsExemptFromLimiters:222, called at:270and:350. The Conference output-cache policies are registered in theConfigureOutputCachecallback (MMCA.ADC/Source/Services/MMCA.ADC.Conference.Service/Program.cs:136), with the public-endpoint policies running fromEventsCache(:175) toBookmarkCountsCache(:216), all throughAddPublicEndpointPolicyexceptSessionsCache, a plainAddPolicyover aPublicEndpointOutputCachePolicythat also bypasses by permission (:186-192),RoomsCache:194,CategoriesCache:195andQuestionsCache:196; the nameConferencePublicCachethe earlier revisions cite no longer exists (the module-wideConferenceCachepolicy,MMCA.ADC/Source/Modules/Conference/MMCA.ADC.Conference.Shared/Caching/ConferenceCacheTags.cs:51, is a plainAddPolicy). Decision item 2 now cites:136,:175-216. InMMCA.ADC/infra/main.bicepRateLimiting__Distributedis set at:2226,:2482,:2622and:2788(rationale:2220-2225),RateLimiting__AuthIpPermitLimit'300'at:2348insideconferenceMode(rationale:2340-2345, whose claim thatProgram.cscalls the configuration overload predates the move intoAddMmcaServiceHost; the key it names is still the right one), service ingress is internal at:2146,:2417,:2571and:2719(theexternal: falseat:2730is Notification's gRPC port mapping), the gateway and UI host are external at:2914and:3077, and the trusted-caller secret is injected at:2990and:3149. InMMCA.Store/infra/main.bicepservice ingress is internal at:1844,:2043and:2167(the:2180entry is Sales' gRPC port mapping), the gateway and UI host are external at:2338and:2467, the trusted-caller secret is injected at:2410and:2535, and the only rate-limiting keys areGatewayRateLimiting__*. Store's gateway declaresRateLimiterPoliciesatMMCA.Store/Source/Hosts/MMCA.Store.Gateway/appsettings.json:37(auth-tight:38), attached toidentity-auth-login(:86-92,:91) andidentity-auth-register(:93-99,:98) with theidentity-authcatch-all at:102carrying none;CredentialRoutes_CarryTheTightRateLimiterPolicyis atMMCA.Store/Tests/Hosts/MMCA.Store.Gateway.Tests/MmcaGatewayTests.cs:127, with the per-route loop at:138and the exact-setBeEquivalentToat:149. Store's UIGatewayRateLimitingsection is atMMCA.Store/Source/Hosts/UI/MMCA.Store.UI.Web/appsettings.json:48, withTrustedCallerHeaderNameat:49. The Trade-offs anchors now cite these lines.
Revision (2026-12-03)
MMCA.Common v1.331.0. The layering, every default, the authenticated-only global limiter and the
forwarded-header trust posture are unchanged. What is new is the partition key every per-IP limiter
uses, now Decision item 6: ClientAddressKey.For masks IPv6 to its /64 and unmaps IPv4-mapped
addresses (MMCA.Common/Source/Build/RateLimiting/ClientAddressKey.cs:42-65), one linked source file
shared by the API, Infrastructure, Aspire, UI.Web and Gateway packages. The registration cap applies
it inside LoginProtectionService (LoginProtectionService.cs:267), so sign-in history still records
the real address. The idempotency anonymous key keeps the raw address (ADR-017). The same folder holds
RetryAfterRejection.cs, the OnRejected wrapper every MMCA limiter installs so a 429 carries
Retry-After when the lease has a hint, linked the same way into the API, Aspire, UI.Web and Gateway
packages (MMCA.Common/Source/Build/RateLimiting/RetryAfterRejection.cs:7-18).
Related
ADR-004 (the JWKS/discovery traffic the limiter exempts, and the authenticated principal it keys on),
ADR-008 (the gateway edge this protects), ADR-017 (request idempotency, the other inbound-edge
safeguard against client retries), ADR-029 (the per-email lockout and registration throttle that sit
on the login and register endpoints the auth-ip cap also covers, and the reason auth-ip stays
local), ADR-026 (the
Redis the distributed limiter reuses, and the IncrementAsync storage-format lesson the INCRBY
Lua script here avoids by owning its own rl: keyspace, qualified per application), ADR-070 (the fail-fast configuration contract
RateLimitingSettings binds into, and the Distributed degradation that sits outside it), ADR-079
(the shared middleware pipeline that places UseRateLimiter after authentication and after forwarded
headers, which is what makes both partition keys resolvable), ADR-135 (the application namespace that
qualifies the distributed limiter's Redis partition key, one rule for every shared infrastructure
keyspace), ADR-138 (the MCP endpoint that is the one caller of the mcp policy).