# CMS-U2 gate-and-limiter: code summary ## What changed - `Core/Availability/PublicSiteEndpointAttribute` (sealed, methods only). `AvailabilityMiddleware`: right after the prefix bypass, an endpoint whose metadata carries the marker is let through before the master/local gate (deny-by-default; prefix bypasses and the verified-admin bypass untouched). Marked now: `OfferingsController.GetOfferings` only. - `AddCmsRateLimiting.OnRejected`: still logs the security event, now also sets `Retry-After` (whole seconds, rounded up, minimum 1, from the limiter lease; 60 when the lease reports none) and writes `application/problem+json` with only `type`, `title`, `status`. Policy numbers and bucket behaviour are unchanged. ## RELEASE CONDITION (must be met before the contact routes go live) On the base branch (master) the rate-limit policies are **global buckets**: there is no per-client partition key and no ForwardedHeaders handling (both exist only on the ASF branch `feature/identity-email-notifications`). Any per-IP policy added in CMS-U3 (ContactForm 5 per 10 minutes, ContactToken 20 per 10 minutes, ContactResend) would therefore be shared by all visitors: after five submissions the whole site would be blocked. **The contact routes must not be enabled on a public host before the per-client partitioning from the ASF branch is on the base branch (after the ASF merge and the rebase).** Also required on that host: `ForwardedHeaders:KnownProxies` (env). Recorded in contract ยง 4.5 and repeated in the CMS-U3 plan. ## Verification (real output) - Build: 0 errors. Tests: Core.Tests 205 passed (9 new in RateLimiterOnRejectedTests: Retry-After rounding, fallback 60, problem+json with exactly type/title/status, no leak of policy name/path/limiter terms, only `Retry-After` and `Content-Type` headers, security event logged once, 429 status), Availability.Tests 95 passed (13 new in PublicSiteEndpointGateTests: marked endpoint passes for CMS disabled / maintenance / master blocks; unmarked, and no endpoint, still 503; Availability/status open; route table: marker on exactly `OfferingsController.GetOfferings`, marked actions are anonymous and never `[Authorize]`, every other action of the Availability/Identity/Master/Offerings/System controllers answers 503 at a closed gate, and the only action that passes is `GetOfferings`), Offerings.Tests 86 passed (2 new marker tests), Identity.Tests 37, Master.Tests 57, Api.Tests 4 passed with a temporary MariaDB (the existing Sentry-tunnel limiter test now also asserts Retry-After, `application/problem+json` and the three-field body). - Real pipeline smoke (SlpSoftware host against the temporary MariaDB, CMS state set via the AvailabilityState table): with the CMS **disabled** `GET /api/v1/offerings` 200, `GET /api/v1/offerings/categories` 503, `GET /api/v1/System/capabilities` 503, `GET /api/v1/Availability/status` 200, unauthenticated `PUT /api/v1/offerings/order` 503; in **maintenance** offerings 200 and capabilities 503. The host was stopped and the container removed afterwards. ## Handoff Public site endpoints stay reachable when the CMS is off or in maintenance; the frontend 503 fallback now only applies to admin calls. Extending the public set is deliberate: add the action to `AllowedPublicActions` in `PublicSiteEndpointGateTests` in the same change (CMS-U3 adds the contact token GET and POST). ## Rebase notes (after the ASF merge) Expected conflicts: `AvailabilityMiddleware.cs` (one block) and `AddCmsRateLimiting` (`OnRejected`). Re-run the Core, Availability and Offerings tests and the Api.Tests after the rebase.