# Code Summary - andreaslop-client (U2) Names follow the ASF convention (see `infrastructure-design.md`). Test environment only; nothing was pushed or deployed. ## Part A - Core: forwarded headers and per-client limiters (option B) - `Core/Hosting/Proxy/ForwardedHeadersSettings.cs`: `ForwardedHeaders:KnownProxies`, `ParseKnownProxies` (unparsable entry and any-address `0.0.0.0`/`::` fail at startup). - `ForwardedHeadersExtensions.cs`: `AddCmsForwardedHeaders` (XForwardedFor|XForwardedProto, ForwardLimit 1, default known proxies/networks cleared) and `UseCmsForwardedHeaders` (adds the middleware only when a proxy is configured). `CmsHost.ConfigurePipeline` calls it first after the database migration. - `ClientPartitionKey.cs` + `AddCmsRateLimiting`: `login`, `refresh`, sentry-tunnel and `offerings-public` are now partitioned per client address (IPv4-mapped IPv6 normalised, fallback key `(unknown)`). - Safe degradation: without `KnownProxies` the headers are ignored and every caller shares the proxy address, i.e. the old single bucket. - Tests (`Core.Tests/Hosting/Proxy`): parsing, partition key (PBT: injective over addresses), TestServer pipeline (no proxy = headers ignored and shared bucket; trusted proxy = real address, scheme and separate buckets; untrusted peer cannot spoof; wildcard fails at startup). ## Part B - Identity: setup token - `Modules.Identity/Setup`: `SetupOptions` (`Identity:Setup:Token`, whitespace-only = startup error via `ValidateOnStart`), `ISetupTokenValidator`/`SetupTokenValidator` (SHA-256 + `CryptographicOperations.FixedTimeEquals`). - `SetupController`: `[EnableRateLimiting("login")]` on both endpoints; `POST owner` requires header `X-Setup-Token` when configured and answers an identical 401 for missing and wrong tokens; `GET status` returns `initialized` + `tokenRequired`. - `SecurityEvents.SetupTokenRejected` (event id 5007, tag `setup_token_rejected`, added to `SecurityEventProcessor`); the presented token is never logged. - Tests: validator (examples, PBT: only the exact token passes, never throws), controller (401 uniformity, no owner created, event logged without the token, header passed on), options validation, security-event tests extended to seven events. ## Part C - Client `SlpModularCms.Api.AndreaSlopFotografie` - New project under Clients: Identity + Availability only (no Master, no Offerings; Availability kept because the admin reads its status). `CmsHostOptions { WebsiteMode = PrerenderedPages }`, `public partial class Program` for host tests. - appsettings.json (no secrets; `SecurityHeaders:DefaultPolicy=StrictSite` + website Umami/Sentry origins for the site lists only, `Website:NoIndex=true`, empty `Identity:Setup:Token` and `ForwardedHeaders:KnownProxies`), appsettings.Development.json (own dev DB, CORS for `pnpm dev:asf`), launchSettings port 5200/7200. `appsettings.local.json` is optional and git-ignored like in the other clients. - Tests project `Api.AndreaSlopFotografie.Tests` (solution folder Tests): `HostConfigurationTests` (5, no database) and `HostPipelineTests` (5, need MariaDB like `Api.Tests`; they run in CI `backend-test`, which starts MariaDB). ## Part D - Frontend - `frontend/themes/asf/theme.css` (website palette exactly, Q5 = B; light and a derived dark variant; Marcellus/Jost self-hosted via `@fontsource/*@5.3.0`), `favicon.svg` (placeholder monogram, see hand-back), `none.css`, `resolveTheme.ts` (unknown theme = build error). `vite.config.ts`: alias `@theme`, favicon plugin. `main.tsx` imports `@theme`. - `VITE_DEFAULT_LANGUAGE`: `parseDefaultLanguage`, `languageDetection` (stored choice > default > browser). - Setup page: token field only when `tokenRequired`, header `X-Setup-Token`, `skipAuthRefresh` so a 401 does not trigger a session refresh; nl/en texts. - Verified: default build unchanged (no theme CSS, no fonts), `VITE_THEME=asf` build contains the palette, 4 woff2 files, no `data:` fonts (admin CSP `font-src 'self'`), favicon link swapped; `VITE_THEME=nope` fails the build. - Vitest 293 passed, ESLint and `tsc -b` clean. ## Part E - CI - `continuous_integration.yaml` only gained the `deploy_asf_test` dispatch input and three jobs at the end (`config-asf`, `publish-asf-test`, `deploy-asf-test`), all gated by `vars.ASF_TEST_DEPLOY_ENABLED == 'true'`. Diff = additions only; `deploy-scp.yaml` unchanged. ## Defect found and fixed in U1 along the way - `WebsitePathResolver` built the 301 `Location` from the decoded path without re-encoding (`/a%3Fb/` redirected to `/a?b`, `#` started a fragment, non-ASCII ended up raw in a header). Found by the existing property test (flaky 1 in ~15 runs); fixed with `PathString.ToUriComponent`, regression tests added, property test now models the browser (splits the Location, decodes the path). ## Not verified here - `Api.Tests` and `Api.AndreaSlopFotografie.Tests/HostPipelineTests` need MariaDB (none on this machine); they run in CI. Behaviour behind the real proxy (forwarded headers, HTTP/1.0), `vars` in job-level `if:` on this Gitea, and the Pi timing are only observable on the first test deploy.