Skip to content

Commit ebd8f21

Browse files
minor #31782 [Security][Http] Remove BC layers (chalasr)
This PR was merged into the 5.0-dev branch. Discussion ---------- [Security][Http] Remove BC layers | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | yes | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a Commits ------- 81e9974 [Security][Http] Remove BC layers
2 parents 1177a2a + 81e9974 commit ebd8f21

21 files changed

+62
-275
lines changed

src/Symfony/Bundle/SecurityBundle/Debug/WrappedListener.php

+4-19
Original file line numberDiff line numberDiff line change
@@ -12,31 +12,24 @@
1212
namespace Symfony\Bundle\SecurityBundle\Debug;
1313

1414
use Symfony\Component\HttpKernel\Event\RequestEvent;
15-
use Symfony\Component\Security\Http\Firewall\LegacyListenerTrait;
16-
use Symfony\Component\Security\Http\Firewall\ListenerInterface;
1715
use Symfony\Component\VarDumper\Caster\ClassStub;
1816

1917
/**
2018
* Wraps a security listener for calls record.
2119
*
2220
* @author Robin Chalas <robin.chalas@gmail.com>
2321
*
24-
* @internal since Symfony 4.3
22+
* @internal
2523
*/
26-
final class WrappedListener implements ListenerInterface
24+
final class WrappedListener
2725
{
28-
use LegacyListenerTrait;
29-
3026
private $response;
3127
private $listener;
3228
private $time;
3329
private $stub;
3430
private static $hasVarDumper;
3531

36-
/**
37-
* @param callable $listener
38-
*/
39-
public function __construct($listener)
32+
public function __construct(callable $listener)
4033
{
4134
$this->listener = $listener;
4235

@@ -45,18 +38,10 @@ public function __construct($listener)
4538
}
4639
}
4740

48-
/**
49-
* {@inheritdoc}
50-
*/
5141
public function __invoke(RequestEvent $event)
5242
{
5343
$startTime = microtime(true);
54-
if (\is_callable($this->listener)) {
55-
($this->listener)($event);
56-
} else {
57-
@trigger_error(sprintf('Calling the "%s::handle()" method from the firewall is deprecated since Symfony 4.3, implement "__invoke()" instead.', \get_class($this)), E_USER_DEPRECATED);
58-
$this->listener->handle($event);
59-
}
44+
($this->listener)($event);
6045
$this->time = microtime(true) - $startTime;
6146
$this->response = $event->getResponse();
6247
}

src/Symfony/Component/Security/CHANGELOG.md

+16-12
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,22 @@ CHANGELOG
44
5.0.0
55
-----
66

7-
* Removed the `AdvancedUserInterface`, use a custom user checker instead.
8-
* Removed `Argon2iPasswordEncoder`, use `SodiumPasswordEncoder` instead
9-
* Removed `BcryptPasswordEncoder`, use `NativePasswordEncoder` instead
10-
* Removed the `has_role()` function from security expressions, use `is_granted()` instead.
11-
* `SimpleAuthenticatorInterface`, `SimpleFormAuthenticatorInterface`, `SimplePreAuthenticatorInterface`,
12-
`SimpleAuthenticationProvider`, `SimpleAuthenticationHandler`, `SimpleFormAuthenticationListener` and
13-
`SimplePreAuthenticationListener` have been removed. Use Guard instead.
14-
* Removed the `Role` and `SwitchUserRole` classes. Use strings for roles instead.
15-
* Removed the `getReachableRoles()` method from the `RoleHierarchyInterface`. Role hierarchies must implement
16-
the `getReachableRoleNames()` method instead and return roles as strings.
17-
* Removed the `getRoles()` method from the `TokenInterface`. Tokens must implement the `getRoleNames()` method
18-
instead and return roles as strings.
7+
* The `FirewallMapInterface::getListeners()` method must return an array of 3 elements.
8+
* Removed the `ContextListener::setLogoutOnUserChange()` method.
9+
* Removed the `ListenerInterface`, turn your listeners into callables instead.
10+
* Removed the `Firewall::handleRequest()` method, use `Firewall::callListeners()` instead.
11+
* Removed the `AdvancedUserInterface`, use a custom user checker instead.
12+
* Removed `Argon2iPasswordEncoder`, use `SodiumPasswordEncoder` instead
13+
* Removed `BcryptPasswordEncoder`, use `NativePasswordEncoder` instead
14+
* Removed the `has_role()` function from security expressions, use `is_granted()` instead.
15+
* `SimpleAuthenticatorInterface`, `SimpleFormAuthenticatorInterface`, `SimplePreAuthenticatorInterface`,
16+
`SimpleAuthenticationProvider`, `SimpleAuthenticationHandler`, `SimpleFormAuthenticationListener` and
17+
`SimplePreAuthenticationListener` have been removed. Use Guard instead.
18+
* Removed the `Role` and `SwitchUserRole` classes. Use strings for roles instead.
19+
* Removed the `getReachableRoles()` method from the `RoleHierarchyInterface`. Role hierarchies must implement
20+
the `getReachableRoleNames()` method instead and return roles as strings.
21+
* Removed the `getRoles()` method from the `TokenInterface`. Tokens must implement the `getRoleNames()` method
22+
instead and return roles as strings.
1923

2024
4.4.0
2125
-----

src/Symfony/Component/Security/Guard/Firewall/GuardAuthenticationListener.php

+2-6
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
use Symfony\Component\Security\Guard\AuthenticatorInterface;
2222
use Symfony\Component\Security\Guard\GuardAuthenticatorHandler;
2323
use Symfony\Component\Security\Guard\Token\PreAuthenticationGuardToken;
24-
use Symfony\Component\Security\Http\Firewall\LegacyListenerTrait;
25-
use Symfony\Component\Security\Http\Firewall\ListenerInterface;
2624
use Symfony\Component\Security\Http\RememberMe\RememberMeServicesInterface;
2725

2826
/**
@@ -31,12 +29,10 @@
3129
* @author Ryan Weaver <ryan@knpuniversity.com>
3230
* @author Amaury Leroux de Lens <amaury@lerouxdelens.com>
3331
*
34-
* @final since Symfony 4.3
32+
* @final
3533
*/
36-
class GuardAuthenticationListener implements ListenerInterface
34+
class GuardAuthenticationListener
3735
{
38-
use LegacyListenerTrait;
39-
4036
private $guardHandler;
4137
private $authenticationManager;
4238
private $providerKey;

src/Symfony/Component/Security/Http/Firewall.php

+4-36
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,12 @@
1111

1212
namespace Symfony\Component\Security\Http;
1313

14-
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
1514
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
1615
use Symfony\Component\HttpKernel\Event\FinishRequestEvent;
17-
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
1816
use Symfony\Component\HttpKernel\Event\RequestEvent;
1917
use Symfony\Component\HttpKernel\KernelEvents;
2018
use Symfony\Component\Security\Http\Firewall\AccessListener;
21-
use Symfony\Component\Security\Http\Firewall\LogoutListener;
19+
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
2220

2321
/**
2422
* Firewall uses a FirewallMap to register security listeners for the given
@@ -38,17 +36,12 @@ class Firewall implements EventSubscriberInterface
3836

3937
public function __construct(FirewallMapInterface $map, EventDispatcherInterface $dispatcher)
4038
{
41-
// the type-hint will be updated to the "EventDispatcherInterface" from symfony/contracts in 5.0
42-
4339
$this->map = $map;
4440
$this->dispatcher = $dispatcher;
4541
$this->exceptionListeners = new \SplObjectStorage();
4642
}
4743

48-
/**
49-
* @internal since Symfony 4.3
50-
*/
51-
public function onKernelRequest(GetResponseEvent $event)
44+
public function onKernelRequest(RequestEvent $event)
5245
{
5346
if (!$event->isMasterRequest()) {
5447
return;
@@ -57,11 +50,6 @@ public function onKernelRequest(GetResponseEvent $event)
5750
// register listeners for this firewall
5851
$listeners = $this->map->getListeners($event->getRequest());
5952

60-
if (3 !== \count($listeners)) {
61-
@trigger_error(sprintf('Not returning an array of 3 elements from %s::getListeners() is deprecated since Symfony 4.2, the 3rd element must be an instance of %s or null.', FirewallMapInterface::class, LogoutListener::class), E_USER_DEPRECATED);
62-
$listeners[2] = null;
63-
}
64-
6553
$authenticationListeners = $listeners[0];
6654
$exceptionListener = $listeners[1];
6755
$logoutListener = $listeners[2];
@@ -93,16 +81,9 @@ public function onKernelRequest(GetResponseEvent $event)
9381
}
9482
};
9583

96-
if ($event instanceof RequestEvent) {
97-
$this->callListeners($event, $authenticationListeners());
98-
} else {
99-
$this->handleRequest($event, $authenticationListeners());
100-
}
84+
$this->callListeners($event, $authenticationListeners());
10185
}
10286

103-
/**
104-
* @internal since Symfony 4.3
105-
*/
10687
public function onKernelFinishRequest(FinishRequestEvent $event)
10788
{
10889
$request = $event->getRequest();
@@ -125,22 +106,9 @@ public static function getSubscribedEvents()
125106
}
126107

127108
protected function callListeners(RequestEvent $event, iterable $listeners)
128-
{
129-
$this->handleRequest($event, $listeners);
130-
}
131-
132-
/**
133-
* @deprecated since Symfony 4.3, use callListeners instead
134-
*/
135-
protected function handleRequest(GetResponseEvent $event, $listeners)
136109
{
137110
foreach ($listeners as $listener) {
138-
if (\is_callable($listener)) {
139-
$listener($event);
140-
} else {
141-
@trigger_error(sprintf('Calling the "%s::handle()" method from the firewall is deprecated since Symfony 4.3, implement "__invoke()" instead.', \get_class($this)), E_USER_DEPRECATED);
142-
$listener->handle($event);
143-
}
111+
$listener($event);
144112

145113
if ($event->hasResponse()) {
146114
break;

src/Symfony/Component/Security/Http/Firewall/AbstractAuthenticationListener.php

+3-6
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Component\Security\Http\Firewall;
1313

1414
use Psr\Log\LoggerInterface;
15-
use Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy;
1615
use Symfony\Component\HttpFoundation\Request;
1716
use Symfony\Component\HttpFoundation\Response;
1817
use Symfony\Component\HttpKernel\Event\RequestEvent;
@@ -49,12 +48,10 @@
4948
* @author Fabien Potencier <fabien@symfony.com>
5049
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
5150
*
52-
* @internal since Symfony 4.3
51+
* @internal
5352
*/
54-
abstract class AbstractAuthenticationListener implements ListenerInterface
53+
abstract class AbstractAuthenticationListener
5554
{
56-
use LegacyListenerTrait;
57-
5855
protected $options;
5956
protected $logger;
6057
protected $authenticationManager;
@@ -95,7 +92,7 @@ public function __construct(TokenStorageInterface $tokenStorage, AuthenticationM
9592
'require_previous_session' => true,
9693
], $options);
9794
$this->logger = $logger;
98-
$this->dispatcher = LegacyEventDispatcherProxy::decorate($dispatcher);
95+
$this->dispatcher = $dispatcher;
9996
$this->httpUtils = $httpUtils;
10097
}
10198

src/Symfony/Component/Security/Http/Firewall/AbstractPreAuthenticatedListener.php

+3-6
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Component\Security\Http\Firewall;
1313

1414
use Psr\Log\LoggerInterface;
15-
use Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy;
1615
use Symfony\Component\HttpFoundation\Request;
1716
use Symfony\Component\HttpKernel\Event\RequestEvent;
1817
use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
@@ -33,12 +32,10 @@
3332
*
3433
* @author Fabien Potencier <fabien@symfony.com>
3534
*
36-
* @internal since Symfony 4.3
35+
* @internal
3736
*/
38-
abstract class AbstractPreAuthenticatedListener implements ListenerInterface
37+
abstract class AbstractPreAuthenticatedListener
3938
{
40-
use LegacyListenerTrait;
41-
4239
protected $logger;
4340
private $tokenStorage;
4441
private $authenticationManager;
@@ -52,7 +49,7 @@ public function __construct(TokenStorageInterface $tokenStorage, AuthenticationM
5249
$this->authenticationManager = $authenticationManager;
5350
$this->providerKey = $providerKey;
5451
$this->logger = $logger;
55-
$this->dispatcher = LegacyEventDispatcherProxy::decorate($dispatcher);
52+
$this->dispatcher = $dispatcher;
5653
}
5754

5855
/**

src/Symfony/Component/Security/Http/Firewall/AccessListener.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,10 @@
2424
*
2525
* @author Fabien Potencier <fabien@symfony.com>
2626
*
27-
* @final since Symfony 4.3
27+
* @final
2828
*/
29-
class AccessListener implements ListenerInterface
29+
class AccessListener
3030
{
31-
use LegacyListenerTrait;
32-
3331
private $tokenStorage;
3432
private $accessDecisionManager;
3533
private $map;

src/Symfony/Component/Security/Http/Firewall/AnonymousAuthenticationListener.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,10 @@
2424
*
2525
* @author Fabien Potencier <fabien@symfony.com>
2626
*
27-
* @final since Symfony 4.3
27+
* @final
2828
*/
29-
class AnonymousAuthenticationListener implements ListenerInterface
29+
class AnonymousAuthenticationListener
3030
{
31-
use LegacyListenerTrait;
32-
3331
private $tokenStorage;
3432
private $secret;
3533
private $authenticationManager;

src/Symfony/Component/Security/Http/Firewall/BasicAuthenticationListener.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,10 @@
2727
*
2828
* @author Fabien Potencier <fabien@symfony.com>
2929
*
30-
* @final since Symfony 4.3
30+
* @final
3131
*/
32-
class BasicAuthenticationListener implements ListenerInterface
32+
class BasicAuthenticationListener
3333
{
34-
use LegacyListenerTrait;
35-
3634
private $tokenStorage;
3735
private $authenticationManager;
3836
private $providerKey;

src/Symfony/Component/Security/Http/Firewall/ChannelListener.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,10 @@
2222
*
2323
* @author Fabien Potencier <fabien@symfony.com>
2424
*
25-
* @final since Symfony 4.3
25+
* @final
2626
*/
27-
class ChannelListener implements ListenerInterface
27+
class ChannelListener
2828
{
29-
use LegacyListenerTrait;
30-
3129
private $map;
3230
private $authenticationEntryPoint;
3331
private $logger;

src/Symfony/Component/Security/Http/Firewall/ContextListener.php

+3-17
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Component\Security\Http\Firewall;
1313

1414
use Psr\Log\LoggerInterface;
15-
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
1615
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
1716
use Symfony\Component\HttpKernel\Event\RequestEvent;
1817
use Symfony\Component\HttpKernel\KernelEvents;
@@ -28,19 +27,18 @@
2827
use Symfony\Component\Security\Core\User\UserInterface;
2928
use Symfony\Component\Security\Core\User\UserProviderInterface;
3029
use Symfony\Component\Security\Http\Event\DeauthenticatedEvent;
30+
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
3131

3232
/**
3333
* ContextListener manages the SecurityContext persistence through a session.
3434
*
3535
* @author Fabien Potencier <fabien@symfony.com>
3636
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
3737
*
38-
* @final since Symfony 4.3
38+
* @final
3939
*/
40-
class ContextListener implements ListenerInterface
40+
class ContextListener
4141
{
42-
use LegacyListenerTrait;
43-
4442
private $tokenStorage;
4543
private $sessionKey;
4644
private $logger;
@@ -66,18 +64,6 @@ public function __construct(TokenStorageInterface $tokenStorage, iterable $userP
6664
$this->trustResolver = $trustResolver ?: new AuthenticationTrustResolver(AnonymousToken::class, RememberMeToken::class);
6765
}
6866

69-
/**
70-
* Enables deauthentication during refreshUser when the user has changed.
71-
*
72-
* @param bool $logoutOnUserChange
73-
*
74-
* @deprecated since Symfony 4.1
75-
*/
76-
public function setLogoutOnUserChange($logoutOnUserChange)
77-
{
78-
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1.', __METHOD__), E_USER_DEPRECATED);
79-
}
80-
8167
/**
8268
* Reads the Security Token from the session.
8369
*/

0 commit comments

Comments
 (0)