// SPDX-License-Identifier: Apache-2.0 package server import ( "os" "strings" ) // Content-Security-Policy for CaddyUI's own UI. // // v2.30.0. The securityHeaders middleware in server.go has set X-Frame-Options, // X-Content-Type-Options and Referrer-Policy since v2.10.3; CSP is the piece // that was missing. The policy is defined here rather than inline so the // allowlist and the reasoning for each entry stay together. // // HSTS remains deliberately unset — see the note on securityHeaders. // defaultCSP allows exactly the third-party origins the templates actually // load, and nothing else. // // - cdn.tailwindcss.com — the Tailwind runtime on authenticated pages // ('unsafe-eval' is required: the Play CDN compiles utility classes in the // browser). Unauthenticated pages use the committed web/static/auth.css // instead and don't touch it. // - challenges.cloudflare.com — Turnstile (script + the widget's iframe) // - www.google.com / www.gstatic.com — reCAPTCHA v3 (script, subresources, // and its iframe) // // 'unsafe-inline' in script-src is unavoidable today: the templates carry ~75 // inline event handlers plus many inline