Skip to content

Commit c6ed734

Browse files
author
Robin Chalas
committed
[Security][Http] Remove BC layers
1 parent 371dfc7 commit c6ed734

21 files changed

+56
-253
lines changed

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

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,17 @@
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;
@@ -45,17 +41,11 @@ public function __construct($listener)
4541
}
4642
}
4743

48-
/**
49-
* {@inheritdoc}
50-
*/
5144
public function __invoke(RequestEvent $event)
5245
{
5346
$startTime = microtime(true);
5447
if (\is_callable($this->listener)) {
5548
($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);
5949
}
6050
$this->time = microtime(true) - $startTime;
6151
$this->response = $event->getResponse();

src/Symfony/Component/Security/CHANGELOG.md

Lines changed: 16 additions & 12 deletions
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.3.0
2125
-----

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

Lines changed: 2 additions & 6 deletions
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

Lines changed: 4 additions & 23 deletions
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,15 @@ 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

4844
/**
49-
* @internal since Symfony 4.3
45+
* @internal
5046
*/
51-
public function onKernelRequest(GetResponseEvent $event)
47+
public function onKernelRequest(RequestEvent $event)
5248
{
5349
if (!$event->isMasterRequest()) {
5450
return;
@@ -57,11 +53,6 @@ public function onKernelRequest(GetResponseEvent $event)
5753
// register listeners for this firewall
5854
$listeners = $this->map->getListeners($event->getRequest());
5955

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-
6556
$authenticationListeners = $listeners[0];
6657
$exceptionListener = $listeners[1];
6758
$logoutListener = $listeners[2];
@@ -95,13 +86,11 @@ public function onKernelRequest(GetResponseEvent $event)
9586

9687
if ($event instanceof RequestEvent) {
9788
$this->callListeners($event, $authenticationListeners());
98-
} else {
99-
$this->handleRequest($event, $authenticationListeners());
10089
}
10190
}
10291

10392
/**
104-
* @internal since Symfony 4.3
93+
* @internal
10594
*/
10695
public function onKernelFinishRequest(FinishRequestEvent $event)
10796
{
@@ -125,14 +114,6 @@ public static function getSubscribedEvents()
125114
}
126115

127116
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)
136117
{
137118
foreach ($listeners as $listener) {
138119
if (\is_callable($listener)) {

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

Lines changed: 3 additions & 6 deletions
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

Lines changed: 3 additions & 6 deletions
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

Lines changed: 2 additions & 4 deletions
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

Lines changed: 2 additions & 4 deletions
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

Lines changed: 2 additions & 4 deletions
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

Lines changed: 2 additions & 4 deletions
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;

0 commit comments

Comments
 (0)