File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed
packages/http/src/Session Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change 88use Tempest \Core \AppConfig ;
99use Tempest \Core \Priority ;
1010use Tempest \Cryptography \Encryption \Encrypter ;
11+ use Tempest \Cryptography \Encryption \Exceptions \EncryptionException ;
1112use Tempest \Http \Cookie \Cookie ;
1213use Tempest \Http \Cookie \CookieManager ;
1314use Tempest \Http \Method ;
@@ -72,9 +73,13 @@ private function ensureTokenMatches(Request $request): void
7273 );
7374
7475 if (! $ tokenFromRequest && $ request ->headers ->has (self ::CSRF_HEADER_KEY )) {
75- $ tokenFromRequest = $ this ->encrypter ->decrypt (
76- urldecode ($ request ->headers ->get (self ::CSRF_HEADER_KEY )),
77- );
76+ try {
77+ $ tokenFromRequest = $ this ->encrypter ->decrypt (
78+ urldecode ($ request ->headers ->get (self ::CSRF_HEADER_KEY )),
79+ );
80+ } catch (EncryptionException ) {
81+ // If decryption fails, treat it as a mismatch
82+ }
7883 }
7984
8085 if (! $ tokenFromRequest ) {
You can’t perform that action at this time.
0 commit comments