8000 Avoid regenerating the remember me token if it is still fresh by Seldaek · Pull Request #40972 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Avoid regenerating the remember me token if it is still fresh #40972

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
May 7, 2021
Merged
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
Avoid regenerating the remember me token if it is still fresh
  • Loading branch information
Seldaek authored Apr 28, 2021
commit a942b5f6849810d45aab163c40381a16d5e8dbd9
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,12 @@ public function processRememberMe(RememberMeDetails $rememberMeDetails, UserInte
throw new AuthenticationException('The cookie has expired.');
}

$tokenValue = base64_encode(random_bytes(64));
$this->tokenProvider->updateToken($series, $this->generateHash($tokenValue), new \DateTime());
// if a token was regenerated less than a minute ago, there is no need to regenerate it
// if multiple concurrent requests reauthenticate a user we do not want to update the token several times
if ($persistentToken->getLastUsed()->getTimestamp() + 60 < time()) {
$tokenValue = base64_encode(random_bytes(64));
$this->tokenProvider->updateToken($series, $this->generateHash($tokenValue), new \DateTime());
}

$this->createCookie($rememberMeDetails->withValue($tokenValue));
}
Expand Down
0