Skip to content

Commit 17f4fe4

Browse files
bug #50582 [Security/Http] Fix false-string handling in RememberMeAuthenticator (ossinkine)
This PR was merged into the 5.4 branch. Discussion ---------- [Security/Http] Fix false-string handling in `RememberMeAuthenticator` | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #... <!-- prefix each issue number with "Fix #", no need to create an issue if none exists, explain below instead --> | License | MIT | Doc PR | symfony/symfony-docs#... <!-- required for new features --> I found some errors "No remember-me cookie is found." in my logs. I didn't find another way to reproduce it other than set "false-string" to the cookie value, for example `0`. This PR fixes this. Commits ------- 87c2bc2 [Security] Fix false-string handling in RememberMeAuthenticator
2 parents 7723dca + 87c2bc2 commit 17f4fe4

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/Symfony/Component/Security/Http/Authenticator/RememberMeAuthenticator.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function supports(Request $request): ?bool
7070
return false;
7171
}
7272

73-
if (!$request->cookies->has($this->cookieName)) {
73+
if (!$request->cookies->has($this->cookieName) || !\is_scalar($request->cookies->all()[$this->cookieName] ?: null)) {
7474
return false;
7575
}
7676

src/Symfony/Component/Security/Http/Tests/Authenticator/RememberMeAuthenticatorTest.php

+3
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ public static function provideSupportsData()
6161
$request = Request::create('/', 'GET', [], ['_remember_me_cookie' => 'rememberme']);
6262
$request->attributes->set(ResponseListener::COOKIE_ATTR_NAME, new Cookie('_remember_me_cookie', null));
6363
yield [$request, false];
64+
65+
$request = Request::create('/', 'GET', [], ['_remember_me_cookie' => '0']);
66+
yield [$request, false];
6467
}
6568

6669
public function testAuthenticate()

0 commit comments

Comments
 (0)