diff --git a/internal/middleware/middleware.go b/internal/middleware/middleware.go index 754ebd1..00d59f7 100644 --- a/internal/middleware/middleware.go +++ b/internal/middleware/middleware.go @@ -21,6 +21,33 @@ import ( // CORSMaxAgeSeconds is the max age for CORS preflight cache (24 hours). const CORSMaxAgeSeconds = 86400 +// HSTSValue is the Strict-Transport-Security header value: one year with +// includeSubDomains. Emitted unconditionally even though pixa listens plain +// HTTP behind a TLS-terminating proxy; browsers ignore an HSTS header received +// over plaintext (RFC 6797 section 8.1), so it never lies about the connection, +// and emitting it here avoids trusting a forwarded-proto header. +const HSTSValue = "max-age=31536000; includeSubDomains" + +// ContentSecurityPolicyValue is the Content-Security-Policy header value. +// default-src 'self' is the baseline and frame-ancestors 'none' is the primary +// clickjacking control. 'unsafe-inline' is required in script-src and style-src +// because the served templates carry inline onclick handlers (generator page) +// and the bundled Tailwind asset injects a runtime