Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b94fef4

Browse filesBrowse files
committed
bug #38396 Handle consecutive supports() calls in the RememberMeAuthenticator (wouterj)
This PR was merged into the 5.1 branch. Discussion ---------- Handle consecutive supports() calls in the RememberMeAuthenticator | Q | A | ------------- | --- | Branch? | 5.1 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #38206 | License | MIT | Doc PR | - If I read the issue correctly, the problem is not so much that `autoLogin()` is called in supports, but that it is called multiple times in the same request (in lazy firewalls). This is fixed by this issue. @qurben or @fancyweb do you have an application with this error, and can you please test the patch in this PR? Please let me know if this actually fixed the issue. (if you can't, I'll create a small demo app to test this one) Commits ------- e0d1867 Handle consecutive supports() calls in the RememberMeAuthenticator
2 parents 40bc14a + e0d1867 commit b94fef4
Copy full SHA for b94fef4

File tree

2 files changed

+15
-0
lines changed
Filter options

2 files changed

+15
-0
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Http/Authenticator/RememberMeAuthenticator.php
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@ public function supports(Request $request): ?bool
5656
return false;
5757
}
5858

59+
// if the attribute is set, this is a lazy firewall. The previous
60+
// support call already indicated support, so return null and avoid
61+
// recreating the cookie
62+
if ($request->attributes->has('_remember_me_token')) {
63+
return null;
64+
}
65+
5966
$token = $this->rememberMeServices->autoLogin($request);
6067
if (null === $token) {
6168
return false;

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Http/Tests/Authenticator/RememberMeAuthenticatorTest.php
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@ public function provideSupportsData()
6060
yield [$this->createMock(TokenInterface::class), null];
6161
}
6262

63+
public function testConsecutiveSupportsCalls()
64+
{
65+
$this->rememberMeServices->expects($this->once())->method('autoLogin')->with($this->request)->willReturn($this->createMock(TokenInterface::class));
66+
67+
$this->assertNull($this->authenticator->supports($this->request));
68+
$this->assertNull($this->authenticator->supports($this->request));
69+
}
70+
6371
public function testAuthenticate()
6472
{
6573
$this->request->attributes->set('_remember_me_token', new RememberMeToken($user = new User('wouter', 'test'), 'main', 'secret'));

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.