Skip to content

Handle consecutive supports() calls in the RememberMeAuthenticator #38396

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ public function supports(Request $request): ?bool
return false;
}

// if the attribute is set, this is a lazy firewall. The previous
// support call already indicated support, so return null and avoid
// recreating the cookie
if ($request->attributes->has('_remember_me_token')) {
return null;
}

$token = $this->rememberMeServices->autoLogin($request);
if (null === $token) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ public function provideSupportsData()
yield [$this->createMock(TokenInterface::class), null];
}

public function testConsecutiveSupportsCalls()
{
$this->rememberMeServices->expects($this->once())->method('autoLogin')->with($this->request)->willReturn($this->createMock(TokenInterface::class));

$this->assertNull($this->authenticator->supports($this->request));
$this->assertNull($this->authenticator->supports($this->request));
}

public function testAuthenticate()
{
$this->request->attributes->set('_remember_me_token', new RememberMeToken($user = new User('wouter', 'test'), 'main', 'secret'));
Expand Down