Skip to content

Commit 0a5712a

Browse files
committed
feature #42050 [Security] Deprecate TokenInterface::isAuthenticated() (chalasr)
This PR was merged into the 5.4 branch. Discussion ---------- [Security] Deprecate `TokenInterface::isAuthenticated()` | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | - | License | MIT | Doc PR | todo From symfony/symfony#41613 (comment) > all unauthenticated token use-cases have been replaced with passports (and the removal of anonymous). This means that if you have a token, it should always be authenticated. Commits ------- 33b8fbdd8a [Security] Deprecate `TokenInterface::isAuthenticated()` and `setAuthenticated()`
2 parents 3180c20 + ea27e5d commit 0a5712a

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

Provider/GuardAuthenticationProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public function authenticate(TokenInterface $token)
9393

9494
// this should never happen - but technically, the token is
9595
// authenticated... so it could just be returned
96-
if ($token->isAuthenticated()) {
96+
if ($token->isAuthenticated(false)) {
9797
return $token;
9898
}
9999

Token/PostAuthenticationGuardToken.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function __construct(UserInterface $user, string $providerKey, array $rol
4949

5050
// this token is meant to be used after authentication success, so it is always authenticated
5151
// you could set it as non authenticated later if you need to
52-
$this->setAuthenticated(true);
52+
$this->setAuthenticated(true, false);
5353
}
5454

5555
/**

Token/PreAuthenticationGuardToken.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function __construct($credentials, string $guardProviderKey)
4242

4343
parent::__construct([]);
4444

45-
// never authenticated
45+
// @deprecated since Symfony 5.4
4646
parent::setAuthenticated(false);
4747
}
4848

@@ -62,6 +62,9 @@ public function getCredentials()
6262
return $this->credentials;
6363
}
6464

65+
/**
66+
* @deprecated since Symfony 5.4
67+
*/
6568
public function setAuthenticated(bool $authenticated)
6669
{
6770
throw new \LogicException('The PreAuthenticationGuardToken is *never* authenticated.');

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy