From da3240dd7fc9a3b47e7b0baec80e47ded1dd40e4 Mon Sep 17 00:00:00 2001 From: Yoann MOROCUTTI Date: Mon, 28 Sep 2026 11:32:50 +0200 Subject: [PATCH 1/2] fix: Remove usage of CsrfTokenManager that do not work with stateless sessions [csrf-token] --- Service/ReplayRequestSignature.php | 11 +---------- Twig/Extension.php | 3 +-- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/Service/ReplayRequestSignature.php b/Service/ReplayRequestSignature.php index 6918936..b70b6c4 100644 --- a/Service/ReplayRequestSignature.php +++ b/Service/ReplayRequestSignature.php @@ -8,8 +8,7 @@ class ReplayRequestSignature { public function __construct( - private string $secret, - private ?CsrfTokenManagerInterface $csrfTokenManager = null + private string $secret ) { } @@ -17,10 +16,6 @@ public function generate(string $token, int $callIndex): string { $tokenId = $this->buildTokenId($token, $callIndex); - if ($this->csrfTokenManager) { - return $this->csrfTokenManager->getToken($tokenId)->getValue(); - } - return hash_hmac('sha256', $tokenId, $this->secret); } @@ -32,10 +27,6 @@ public function isValid(string $token, int $callIndex, ?string $submittedToken): $tokenId = $this->buildTokenId($token, $callIndex); - if ($this->csrfTokenManager) { - return $this->csrfTokenManager->isTokenValid(new CsrfToken($tokenId, $submittedToken)); - } - return hash_equals($this->generate($token, $callIndex), $submittedToken); } diff --git a/Twig/Extension.php b/Twig/Extension.php index 0587298..35de9c3 100644 --- a/Twig/Extension.php +++ b/Twig/Extension.php @@ -16,8 +16,7 @@ class Extension extends AbstractExtension public function __construct( protected LoaderInterface $loader, private ?ReplayRequestSignature $replayRequestSignature = null - ) - { + ) { } public function getName(): string From 703c232e011fdfd977cd8bcf97754c7a463165f0 Mon Sep 17 00:00:00 2001 From: Yoann MOROCUTTI Date: Mon, 28 Sep 2026 11:55:31 +0200 Subject: [PATCH 2/2] ci: Update PHPUnit configuration file to remove warning from deprecated configuration [csrf-token] --- phpunit.xml.dist | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 742d64e..bbf1bc3 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,6 +1,8 @@ -./Tests - + - . + ./Http + ./Service + + ./vendor + ./Tests + + + + - - - ./Http - ./Service - - ./vendor - ./Tests - - - - - - - \ No newline at end of file +