Skip to content

Commit

Permalink
Prevent refreshing non-expired token
Browse files Browse the repository at this point in the history
  • Loading branch information
stloyd committed Aug 26, 2023
1 parent 4cd1b8e commit 0732506
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
Changelog
=========
## 2.0.0-BETA3 (2022-xx-xx)
## 2.0.0 (2023-xx-xx)
* Bugfix: Prevent refreshing non-expired tokens

## 2.0.0-BETA3 (2023-08-20)
* BC Break: Dropped support for Symfony: 6.0.*,
* BC Break: Class `Templating\Helper\OAuthHelper` was merged into `Twig\Extension\OAuthRuntime`,
* BC Break: When resource owner class doesn't define `TYPE` constant or is `null`, then key will be calculated by converting its class name without `ResourceOwner` suffix to `snake_case`, if neither is felt, then `\LogicException` will be thrown,
Expand Down
4 changes: 4 additions & 0 deletions src/Security/Http/Authenticator/OAuthAuthenticator.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ public function authenticate(Request $request): Passport
*/
public function refreshToken(OAuthToken $token): OAuthToken
{
if (!$token->isExpired() && null !== $token->getUser()) {
return $this->recreateToken($token, $token->getUser());
}

$resourceOwner = $this->resourceOwnerMap->getResourceOwnerByName($token->getResourceOwnerName());
if (!$resourceOwner) {
throw new AuthenticationServiceException('Unknown resource owner set on token: '.$token->getResourceOwnerName());
Expand Down

0 comments on commit 0732506

Please sign in to comment.