Skip to content

Commit 47f3116

Browse files
committed
Added deprecation for RememberMe services without logout() method
1 parent cf04f1e commit 47f3116

File tree

5 files changed

+15
-2
lines changed

5 files changed

+15
-2
lines changed

UPGRADE-5.1.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ Security
167167

168168
* Deprecated `LogoutSuccessHandlerInterface` and `LogoutHandlerInterface`, register a listener on the `LogoutEvent` event instead.
169169
* Deprecated `DefaultLogoutSuccessHandler` in favor of `DefaultLogoutListener`.
170+
* Deprecated `RememberMeServicesInterface` implementations without a `logout(Request $request, Response $response, TokenInterface $token)` method.
170171

171172
Yaml
172173
----

UPGRADE-6.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ Security
113113
* Removed `ROLE_PREVIOUS_ADMIN` role in favor of `IS_IMPERSONATOR` attribute
114114
* Removed `LogoutSuccessHandlerInterface` and `LogoutHandlerInterface`, register a listener on the `LogoutEvent` event instead.
115115
* Removed `DefaultLogoutSuccessHandler` in favor of `DefaultLogoutListener`.
116+
* Added a `logout(Request $request, Response $response, TokenInterface $token)` method to the `RememberMeServicesInterface`.
116117

117118
Yaml
118119
----

src/Symfony/Component/Security/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ CHANGELOG
1111
* Deprecated `LogoutSuccessHandlerInterface` and `LogoutHandlerInterface` in favor of listening on the `LogoutEvent`.
1212
* Added experimental new security using `Http\Authenticator\AuthenticatorInterface`, `Http\Authentication\AuthenticatorManager` and `Http\Firewall\AuthenticatorManagerListener`.
1313
* Added `CustomUserMessageAccountStatusException` to be used when extending `UserCheckerInterface`
14+
* Deprecated `RememberMeServicesInterface` implementations without `logout(Request $request, Response $response, TokenInterface $token)` method, this method will be required in Symfony 6.0.
1415

1516
5.0.0
1617
-----

src/Symfony/Component/Security/Http/EventListener/RememberMeLogoutListener.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
1515
use Symfony\Component\Security\Core\Exception\LogicException;
1616
use Symfony\Component\Security\Http\Event\LogoutEvent;
17-
use Symfony\Component\Security\Http\Logout\LogoutHandlerInterface;
17+
use Symfony\Component\Security\Http\RememberMe\RememberMeServicesInterface;
1818

1919
/**
2020
* @author Wouter de Jong <wouter@wouterj.nl>
@@ -25,13 +25,21 @@ class RememberMeLogoutListener implements EventSubscriberInterface
2525
{
2626
private $rememberMeServices;
2727

28-
public function __construct(LogoutHandlerInterface $rememberMeServices)
28+
public function __construct(RememberMeServicesInterface $rememberMeServices)
2929
{
30+
if (!method_exists('logout', $rememberMeServices)) {
31+
trigger_deprecation('symfony/security-core', '5.1', '"%s" should implement the "logout(Request $request, Response $response, TokenInterface $token)" method, this method will be added to the "%s" in version 6.0.', get_class($rememberMeServices), RememberMeServicesInterface::class);
32+
}
33+
3034
$this->rememberMeServices = $rememberMeServices;
3135
}
3236

3337
public function onLogout(LogoutEvent $event): void
3438
{
39+
if (!method_exists('logout', $this->rememberMeServices)) {
40+
return;
41+
}
42+
3543
if (null === $event->getResponse()) {
3644
throw new LogicException(sprintf('No response was set for this logout action. Make sure the DefaultLogoutListener or another listener has set the response before "%s" is called.', __CLASS__));
3745
}

src/Symfony/Component/Security/Http/RememberMe/RememberMeServicesInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
* - PersistentTokenBasedRememberMeServices (requires a TokenProvider)
2525
*
2626
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
27+
*
28+
* @method logout(Request $request, Response $response, TokenInterface $token)
2729
*/
2830
interface RememberMeServicesInterface
2931
{

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