Files
slp-modular-cms/aidlc-docs/features/andreaslop-site-hosting/inception/application-design/components.md
T

4.4 KiB

Components - andreaslop-site-hosting

Numbering follows the brief (C1-C6); C7 is added by this design (setup token, requirements FR-U2-07).

C2 WebsiteMode option (Core, SlpModularCms.Core.Hosting)

  • Purpose: Per-client choice of how the public website is served.
  • Responsibilities: enum WebsiteMode { SpaFallback, PrerenderedPages }; property CmsHostOptions.WebsiteMode (default SpaFallback).
  • Interface: read by CmsHost.ConfigureServices/ConfigurePipeline and StaticContentExtensions.

C3 Prerendered site serving (Core, SlpModularCms.Core.Hosting.Website, new folder)

Active only when WebsiteMode = PrerenderedPages.

Part Kind Responsibility
C3a WebsitePathResolver static, pure Total function: (raw path, query string, Func<string,bool> fileExists) -> WebsiteResolution (ServeFile(relativePath), Redirect(location), NotFound). Contains every nginx-parity rule (canonical form, trailing slash, /index, traversal and backslash rejection, file-looking paths, reserved prefixes). No I/O, no clock, no logging.
C3b WebsiteOptions options Website:NoIndex (default false), validated at startup.
C3c PrerenderedSiteMiddleware middleware Adapter between HTTP and the resolver: supplies the file-exists predicate (confined to wwwroot/web), writes status, Location, Cache-Control, X-Robots-Tag, streams the file, serves 404.html with status 404, answers /robots.txt when NoIndex. Never handles reserved prefixes.
C3d Website compression registration Built-in response compression for the text MIME types, applied only to non-reserved paths (UseWhen), so /api/v1 and /admin responses are never compressed by this feature.

C4 StrictSite policy (Core, SlpModularCms.Core.Hosting.Security)

  • Purpose: A third CSP policy for a prerendered public site, reproducing the site's current header byte for byte.
  • Responsibilities: CspPolicyCatalog.StrictSite constant, added to KnownPolicies; Build produces the site CSP with X-Frame-Options: DENY and Referrer-Policy: strict-origin-when-cross-origin; SecurityHeadersOptions gains AllowedSiteScriptOrigins and AllowedSiteConnectOrigins, used only by StrictSite (decision Q1=A). Strict and Relaxed outputs are unchanged.
  • Check: HSTS, X-Content-Type-Options, Referrer-Policy and the CSP appear on website pages, assets, 301s, 404 and robots.txt (FR-U1-09). The existing writer emits CSP/frame/referrer as "HTML-only" headers; whether non-HTML website responses also need them is settled in U1 Functional Design.

C1 Client SlpModularCms.Api.AndreaSlopFotografie (Clients)

  • Purpose: Deployable host for Andrea's instance.
  • Responsibilities: thin Program.cs on CmsHost with WebsiteMode.PrerenderedPages; .csproj references the modules (Core, Identity, and Availability only if the admin needs it); three-file appsettings; own database connection string template (no password in repo); own dev port; SecurityHeaders:DefaultPolicy = StrictSite plus the site origin lists; Website:NoIndex = true for test.

C5 Admin theme (frontend)

  • Purpose: Per-site look of the admin, fixed at build time.
  • Responsibilities: frontend/themes/<name>/theme.css overriding existing design tokens; theme assets (logo, favicon, self-hosted Marcellus and Jost); build-time selection by VITE_THEME; VITE_DEFAULT_LANGUAGE initial language (user choice still wins); unset variables reproduce today's admin.

C6 CI/CD (Gitea workflows)

  • Purpose: Build and deploy each client with its own admin build.
  • Responsibilities: per-client admin build (VITE_THEME, VITE_DEFAULT_LANGUAGE, VITE_APP_TITLE), ARM64 publish of the new host, deploy to the test Pi using the existing atomic release switch, wwwroot/web outside the release directory; production path of Api.SlpSoftware untouched.

C7 First-admin setup token (Identity module + frontend)

  • Purpose: Stop a stranger from claiming the first administrator on a freshly deployed, publicly reachable instance.
  • Responsibilities: SetupOptions (Identity:Setup:Token, optional); ISetupTokenValidator (constant-time compare, true when no token is configured); SetupController.GetStatus returns tokenRequired; CreateOwner requires header X-Setup-Token when configured; setup page in the frontend shows a token field only when tokenRequired is true (decision Q3=A). Existing hosts without the setting behave exactly as before.