8000 Fix false-string handling in RememberMeAuthenticator · symfony/symfony@9250444 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9250444

Browse files
committed
Fix false-string handling in RememberMeAuthenticator
1 parent e789e08 commit 9250444

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public function supports(Request $request): ?bool
8585
public function authenticate(Request $request): PassportInterface
8686
{
8787
$rawCookie = $request->cookies->get($this->cookieName);
88-
if (!$rawCookie) {
88+
if (!is_string($rawCookie) || '' === $rawCookie) {
8989
throw new \LogicException('No remember-me cookie is found.');
9090
}
9191

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

Lines changed: 11 additions & 0 deletions
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, null];
6467
}
6568

6669
public function testAuthenticate()
@@ -97,4 +100,12 @@ public function testAuthenticateWithTokenWithoutDelimiter()
97100
$request = Request::create('/', 'GET', [], ['_remember_me_cookie' => 'invalid']);
98101
$this->authenticator->authenticate($request);
99102
}
103+
104+
public function testAuthenticateWithFalseToken()
105+
{
106+
$this->expectException(AuthenticationException::class);
107+
108+
$request = Request::create('/', 'GET', [], ['_remember_me_cookie' => '0']);
109+
$this->authenticator->authenticate($request);
110+
}
100111
}

0 commit comments

Comments
 (0)
0