Save consent without reloading the page

consent.js posts the consent form in the background, the server answers
204 with the cookie, and the script swaps in the embeds and the legal line
from a fresh copy of the page. Embed hosts are in frame-src from the start,
the content address still only after consent. Without JavaScript the form
keeps working with a reload.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
kantarciandClaude Opus 5.5 committed 2026-10-12 13:56:16 +02:00
1 parent 6390c00876
commit 6fa303f901
8 files changed
+198 -24

No files matched your search

+6 -1
View File
@@ -33,7 +33,12 @@ final class ConsentController extends AbstractController
'none' => [],
default => array_map(static fn (mixed $group): string => (string) $group, (array) $request->request->all('groups')),
};
$response = $this->redirect($this->backTo($request));
// consent.js schickt dasselbe Formular im Hintergrund und kennzeichnet das mit dieser
// Kopfzeile: dann keine Weiterleitung, nur das Cookie - die Seite bleibt stehen und das
// Skript tauscht aus, was jetzt geladen werden darf (ADR 115). Ein fremdes Formular kann
// die Kopfzeile nicht setzen; ein fremdes Skript bräuchte dafür eine CORS-Freigabe.
$response = '1' === $request->headers->get('X-Kant-Consent') ? new Response(status: Response::HTTP_NO_CONTENT) : $this->redirect($this->backTo($request));
$response->headers->set('Cache-Control', 'no-store');
// Eine Entscheidung trifft nur der eigene Browser auf dieser Website. Ein fremdes Formular,
// das hierher postet, darf keine Einwilligung eintragen - die Route hat keine Sitzung und
// damit kein CSRF-Token, also entscheidet die Herkunft der Anfrage.