5.0 KiB
5.0 KiB
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-address0.0.0.0/::fail at startup).ForwardedHeadersExtensions.cs:AddCmsForwardedHeaders(XForwardedFor|XForwardedProto, ForwardLimit 1, default known proxies/networks cleared) andUseCmsForwardedHeaders(adds the middleware only when a proxy is configured).CmsHost.ConfigurePipelinecalls it first after the database migration.ClientPartitionKey.cs+AddCmsRateLimiting:login,refresh, sentry-tunnel andofferings-publicare now partitioned per client address (IPv4-mapped IPv6 normalised, fallback key(unknown)).- Safe degradation: without
KnownProxiesthe 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 viaValidateOnStart),ISetupTokenValidator/SetupTokenValidator(SHA-256 +CryptographicOperations.FixedTimeEquals).SetupController:[EnableRateLimiting("login")]on both endpoints;POST ownerrequires headerX-Setup-Tokenwhen configured and answers an identical 401 for missing and wrong tokens;GET statusreturnsinitialized+tokenRequired.SecurityEvents.SetupTokenRejected(event id 5007, tagsetup_token_rejected, added toSecurityEventProcessor); 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 Programfor host tests. - appsettings.json (no secrets;
SecurityHeaders:DefaultPolicy=StrictSite+ website Umami/Sentry origins for the site lists only,Website:NoIndex=true, emptyIdentity:Setup:TokenandForwardedHeaders:KnownProxies), appsettings.Development.json (own dev DB, CORS forpnpm dev:asf), launchSettings port 5200/7200.appsettings.local.jsonis optional and git-ignored like in the other clients. - Tests project
Api.AndreaSlopFotografie.Tests(solution folder Tests):HostConfigurationTests(5, no database) andHostPipelineTests(5, need MariaDB likeApi.Tests; they run in CIbackend-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.tsximports@theme.VITE_DEFAULT_LANGUAGE:parseDefaultLanguage,languageDetection(stored choice > default > browser).- Setup page: token field only when
tokenRequired, headerX-Setup-Token,skipAuthRefreshso a 401 does not trigger a session refresh; nl/en texts. - Verified: default build unchanged (no theme CSS, no fonts),
VITE_THEME=asfbuild contains the palette, 4 woff2 files, nodata:fonts (admin CSPfont-src 'self'), favicon link swapped;VITE_THEME=nopefails the build. - Vitest 293 passed, ESLint and
tsc -bclean.
Part E - CI
continuous_integration.yamlonly gained thedeploy_asf_testdispatch input and three jobs at the end (config-asf,publish-asf-test,deploy-asf-test), all gated byvars.ASF_TEST_DEPLOY_ENABLED == 'true'. Diff = additions only;deploy-scp.yamlunchanged.
Defect found and fixed in U1 along the way
WebsitePathResolverbuilt the 301Locationfrom 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 withPathString.ToUriComponent, regression tests added, property test now models the browser (splits the Location, decodes the path).
Not verified here
Api.TestsandApi.AndreaSlopFotografie.Tests/HostPipelineTestsneed MariaDB (none on this machine); they run in CI. Behaviour behind the real proxy (forwarded headers, HTTP/1.0),varsin job-levelif:on this Gitea, and the Pi timing are only observable on the first test deploy.