Beschikbaarheidspoort blokkeert alleen de API, niet de website en de admin
Een uitgeschakeld CMS gaf een kale 503 op de publieke website en op /admin, omdat de poort elk pad stopte dat niet op de bypass-lijst stond. Sinds de host website en admin zelf serveert, viel dat verkeer eronder en kon de admin-app de status niet lezen om de uitgeschakeld-kaart te tonen. Nu worden alleen paden onder /api/ beoordeeld; alle andere paden gaan door. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
# Bug Fix: a disabled CMS answers a bare 503 on the website and on /admin
|
||||
|
||||
- **Slug**: availability-gate-blocks-website-and-admin
|
||||
- **Status**: Complete (pending deploy)
|
||||
- **Issue**: None (reported by Bryan via "CMS & API", 2026-11-09)
|
||||
- **Branch**: feature/identity-email-notifications
|
||||
- **Started**: 2026-11-09
|
||||
- **Documentation Language**: English
|
||||
- **Conversation Language**: Dutch (user language)
|
||||
|
||||
## Report
|
||||
|
||||
**Reproduction**: on ASF test, the master switches the CMS to "not available". Then `test.andreaslop.nl` (the public website) and `/admin` answer a bare 503 (JSON / browser error page).
|
||||
|
||||
**Expected** (Bryan): the public website keeps working; `/admin` loads and shows the dashboard with the "CMS disabled" card, as on SlpSoftware. **Actual**: 503 for everything that is not on the gate's bypass list.
|
||||
|
||||
**Environment**: ASF test (website in PrerenderedPages mode, admin files served by the host itself).
|
||||
|
||||
## Root Cause
|
||||
|
||||
`AvailabilityMiddleware` applied the gate to EVERY path except a short bypass list (`/api/v1/Availability/status`, `/api/v1/Auth/`, `/api/v1/Setup/status`, `/api/v1/master/`, `/api/v1/SlaveStatus`, `/health`). It runs before the static content and the website, so once the host served the website pages and the admin files itself (PrerenderedPages mode), those requests were stopped as well, and the SPA never loaded to read the open status endpoint. On SlpSoftware nginx serves the SPA and only `/api` reaches the host, so only API calls were blocked and the SPA could show its card: the flaw was hidden, not absent. (The same holds on any host that serves `/admin` itself.)
|
||||
|
||||
**Confirmed with user**: relayed by "CMS & API" (Bryan decided: website keeps working, `/admin` loads).
|
||||
|
||||
## The Fix
|
||||
|
||||
`AvailabilityMiddleware` gates only paths under `/api/` (the prefix every controller gets). Everything else (the website, `/admin` files and SPA fallback, the 404 page, `/health`, `/sentry-tunnel`) passes straight through, and a request outside the API is no longer even checked for a bearer token (so the `admin_bypass_rejected ... Expired` noise for asset requests disappears too). The bypass list under `/api/` is unchanged (status, auth, setup status, master, slave status), and an admin with a valid token still passes the gate for the rest of the API.
|
||||
|
||||
Behaviour change for other hosts: on hosts that serve only the API behind nginx nothing changes (their non-API paths never reach the host); on hosts that serve `/admin` or the website themselves the website and admin now stay reachable while the CMS is disabled. `/sentry-tunnel` also stays reachable (it was blocked before).
|
||||
|
||||
## Verification
|
||||
|
||||
**Path used**: Automated test framework (`AvailabilityGateScopeTests`, `AvailabilityGateOnTheRealPipelineTests`, existing middleware tests adapted to API paths).
|
||||
|
||||
**Before the fix**: with the old gate 16 of the new tests fail (website, admin files, `/robots.txt`, `/sentry-tunnel`, 404 page, master gate all answered 503).
|
||||
|
||||
**After the fix**: Availability.Tests 109 pass. Real pipeline (prerendered website + admin files + stand-in API + the real gate), CMS not available or in maintenance: `/`, `/over-mij`, `/admin/`, `/admin/index.html`, `/admin/assets/...`, an `/admin/...` client route, `/health` all 200, an unknown path the website 404 page, `/api/v1/Availability/status` 200 (the admin app reads it), `/api/v1/Users` 503; with the CMS available `/api/v1/Users` is 200; master switching the CMS off behaves the same. Unit level: every non-API path passes through for local not-available, maintenance and the master gate; `/api/v1/Users`, `/api/v1/Offerings/...`, `/api/v1/System/capabilities` (also `/API/V1/...`) stay 503; the open API endpoints stay open; no token validation outside the API.
|
||||
|
||||
## Result
|
||||
|
||||
- **PR(s)**: None
|
||||
- **Commit(s)**: see branch history
|
||||
- **Completed**: 2026-11-09
|
||||
Reference in New Issue
Block a user