Skip to content

Commit c49d00f

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

File tree

5 files changed

+15
-2
lines changed

5 files changed

+15
-2
lines changed

UPGRADE-5.1.md

+1
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

+1
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

+1
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

+10-2
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 <[email protected]>
@@ -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($rememberMeServices, 'logout')) {
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($this->rememberMeServices, 'logout')) {
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

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
* - PersistentTokenBasedRememberMeServices (requires a TokenProvider)
2525
*
2626
* @author Johannes M. Schmitt <[email protected]>
27+
*
28+
* @method logout(Request $request, Response $response, TokenInterface $token)
2729
*/
2830
interface RememberMeServicesInterface
2931
{

0 commit comments

Comments
 (0)