Files
2026-11-06 16:11:44 +01:00

37 lines
4.6 KiB
Markdown

# Hand-back U1 - core-site-hosting
Branch `feature/andreaslop-site-hosting` (2 local commits, not pushed). Code summary: `construction/core-site-hosting/code/code-summary.md`.
## 1. What was built
- `CmsHostOptions.WebsiteMode` (`SpaFallback` default, `PrerenderedPages`); existing clients unchanged.
- Pure `WebsitePathResolver` (rules R1-R14), `PrerenderedSiteMiddleware`, final 404 fallback, gzip-only compression, `Website:NoIndex` (X-Robots-Tag + robots.txt), `WebsiteFileAccess` (per-request file lookup, no cache, no restart after delivery).
- `StrictSite` policy with `SecurityHeaders:AllowedSiteScriptOrigins` / `AllowedSiteConnectOrigins` (used only by StrictSite); CSP is byte-identical to the nginx value (asserted in a test with the Umami and Sentry origins).
- Full header set on every website response (page, asset, 301, 404, robots.txt) via a flag on the security-header writer; API and admin keep the HTML-only rule.
- Docs: `WEBSITE_WORKSPACE.md`, `README.md`.
Deviations from the brief (reasons in code-summary.md): none in behaviour. Behaviour choices you reviewed: R11 nginx parity (301 on every trailing slash), dot segments refused except `/.well-known/`, full headers everywhere, gzip only, logging category `SlpModularCms.Website`.
Behaviour notes for the verify script: 405 (`Allow: GET, HEAD`) for non-GET/HEAD on non-reserved paths that no endpoint claims; `HEAD` is supported; `Location` is always relative; `/404` and `/404.html` answer the 404 page with status 404; a directory without a page file is 404; unknown `/api/v1/...` is an empty API 404.
## 2. Test results
- Build: success. `Core.Tests`: 330 passed (resolver examples, FsCheck properties, StrictSite policy, 25 in-memory integration scenarios). `Modules.Identity.Tests` 37, `Master` 57, `Offerings` 57, `Availability` 82: all passed.
- Property-based: FsCheck.Xunit 3.4.0 (test-only), 2000 generated paths per property, a new random seed each run; a failure prints the replay seed and the shrunk counterexample, which is then pinned as a plain example test (PBT-08). Properties: resolver never throws, ServeFile paths safe and existing, Redirect targets relative and never ending in `/` (except `/`), a redirect target never redirects again, reserved prefixes never resolved, at most 2 file checks; CSP origin round trip.
- Regression `Api` / `Api.SlpSoftware`: `Api.Tests` (the only host test project; SlpSoftware has none) **could not run here**: it needs a reachable MariaDB and failed with socket errors at the startup migration. Not a code failure, but also not proven green. `Api` and `Api.SlpSoftware` build, default to `SpaFallback`, and a SpaFallback-mode integration test shows unchanged behaviour. Please run `Api.Tests` where a database exists (or I run it on the Pi in U2).
- Local timing: 500 `GET /over-mij` on an in-memory server = 0.72 ms per request (not a Pi measurement).
## 3. Configuration values for the website repo
- Client opt-in: `new CmsHostOptions { WebsiteMode = WebsiteMode.PrerenderedPages }` (done in U2 in `Api.AndreaSlopFotografie`).
- `SecurityHeaders:DefaultPolicy = StrictSite`; `AllowedSiteScriptOrigins = [https://analytics.slpsoftware.nl]`; `AllowedSiteConnectOrigins = [https://analytics.slpsoftware.nl, https://o4511795618185216.ingest.de.sentry.io]`.
- `Website:NoIndex = true` on test.
- Headers sent on every website response: CSP (exact nginx string), `Strict-Transport-Security: max-age=31536000; includeSubDomains` (not in Development), `X-Content-Type-Options: nosniff`, `X-Frame-Options: DENY`, `Referrer-Policy: strict-origin-when-cross-origin`; plus `X-Robots-Tag: noindex, nofollow` when NoIndex.
- Cache-Control: `no-cache` for pages/root files, `public, max-age=31536000, immutable` under `/assets/`. HTML content type `text/html; charset=utf-8`.
- Delivery path: `wwwroot/web/` of the published app (U2 decides whether CI writes there or a symlink to `/mnt/storage1/www/html/...`; both work without restart). Hostname, ports (5200 test) and the test deploy come with U2.
- Logging: `Logging:LogLevel:SlpModularCms.Website = Information` on test (301/404 lines), Warning elsewhere.
## 4. Open questions and risks
1. `Api.Tests` not run (no database); see section 2.
2. HSTS is not sent when the host runs in `Development`; irrelevant on the Pi, relevant for local verify runs.
3. Behind the proxy Pi the host sees plain HTTP; redirects are relative and `UseHttpsRedirection` stays a no-op, covered by a test, not yet observed on the Pi.
4. No forwarded-headers handling was added; nothing in U1 needs the original scheme or host.
5. Per-request file lookup is not measured on the Pi SD card / `/mnt/storage1`; I expect it to be fine, a measurement can follow in U2.