Send a Content-Security-Policy and security headers on every response
CI / Deploy / test (push) Successful in 1m1s
CI / Deploy / deploy (push) Skipped

- New SecurityHeadersMiddleware (outermost): CSP with a per-request script
  nonce, framing (SAMEORIGIN, embeds via frame-ancestors), nosniff,
  Referrer- and Permissions-Policy. JSON, files and error pages are covered
  now, not only rendered HTML; headers set by controllers still win.
- The inline theme script carries the nonce; flash messages are dismissed
  via data-dismiss instead of inline onclick handlers, and the flash
  elements share one template.
- reCAPTCHA sources are only allowed when it is enabled.
- The embed CSRF exception and framing use the same isEmbed() check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
gnilebeinandClaude Opus 5.5 committed 2026-11-08 22:43:36 +01:00
1 parent 6912d045cf
commit 2a53675ce5
15 files changed
+290 -66

No files matched your search

+4 -1
View File
@@ -7,11 +7,14 @@
* @var \App\View\AppView $this
* @var string $key localStorage key (presenter uses its own, the beamer is not the laptop)
* @var string $fallback Theme without stored choice: '' = follow the system, 'dark' or 'light'
*
* Carries the CSP nonce of the request (see \App\Middleware\SecurityHeadersMiddleware).
*/
$key ??= 'plenario-theme';
$fallback ??= '';
$nonce = (string)$this->getRequest()->getAttribute('cspScriptNonce', '');
?>
<script>
<script<?= $nonce !== '' ? ' nonce="' . h($nonce) . '"' : '' ?>>
(function () {
var theme = <?= json_encode($fallback) ?>;
try {