Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5dd70bd

Browse files
committed
[Security] Move AbstractListener abstract methods to the new FirewallListenerInterface
1 parenteb8d909 commit5dd70bd

File tree

8 files changed

+55
-23
lines changed

8 files changed

+55
-23
lines changed

‎src/Symfony/Bundle/SecurityBundle/Debug/TraceableFirewallListener.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
useSymfony\Bundle\SecurityBundle\Security\FirewallContext;
1616
useSymfony\Bundle\SecurityBundle\Security\LazyFirewallContext;
1717
useSymfony\Component\HttpKernel\Event\RequestEvent;
18-
useSymfony\Component\Security\Http\Firewall\AbstractListener;
18+
useSymfony\Component\Security\Http\Firewall\FirewallListenerInterface;
1919

2020
/**
2121
* Firewall collecting called listeners.
@@ -41,7 +41,7 @@ protected function callListeners(RequestEvent $event, iterable $listeners)
4141
\Closure::bind(function ()use (&$wrappedLazyListeners, &$wrappedListeners) {
4242
$listeners = [];
4343
foreach ($this->listenersas$listener) {
44-
if ($listenerinstanceofAbstractListener) {
44+
if ($listenerinstanceofFirewallListenerInterface) {
4545
$listener =newWrappedLazyListener($listener);
4646
$listeners[] =$listener;
4747
$wrappedLazyListeners[] =$listener;
@@ -58,7 +58,7 @@ protected function callListeners(RequestEvent $event, iterable $listeners)
5858

5959
$listener($event);
6060
}else {
61-
$wrappedListener =$listenerinstanceofAbstractListener ?newWrappedLazyListener($listener) :newWrappedListener($listener);
61+
$wrappedListener =$listenerinstanceofFirewallListenerInterface ?newWrappedLazyListener($listener) :newWrappedListener($listener);
6262
$wrappedListener($event);
6363
$wrappedListeners[] =$wrappedListener->getInfo();
6464
}

‎src/Symfony/Bundle/SecurityBundle/Debug/WrappedLazyListener.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
useSymfony\Component\HttpKernel\Event\RequestEvent;
1616
useSymfony\Component\Security\Core\Exception\LazyResponseException;
1717
useSymfony\Component\Security\Http\Firewall\AbstractListener;
18+
useSymfony\Component\Security\Http\Firewall\FirewallListenerInterface;
1819

1920
/**
2021
* Wraps a lazy security listener.
@@ -27,7 +28,7 @@ final class WrappedLazyListener extends AbstractListener
2728
{
2829
use TraceableListenerTrait;
2930

30-
publicfunction__construct(AbstractListener$listener)
31+
publicfunction__construct(FirewallListenerInterface$listener)
3132
{
3233
$this->listener =$listener;
3334
}

‎src/Symfony/Bundle/SecurityBundle/Security/LazyFirewallContext.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
useSymfony\Component\HttpKernel\Event\RequestEvent;
1515
useSymfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
1616
useSymfony\Component\Security\Http\Event\LazyResponseEvent;
17-
useSymfony\Component\Security\Http\Firewall\AbstractListener;
1817
useSymfony\Component\Security\Http\Firewall\ExceptionListener;
18+
useSymfony\Component\Security\Http\Firewall\FirewallListenerInterface;
1919
useSymfony\Component\Security\Http\Firewall\LogoutListener;
2020

2121
/**
@@ -46,9 +46,9 @@ public function __invoke(RequestEvent $event)
4646
$lazy =$request->isMethodCacheable();
4747

4848
foreach (parent::getListeners()as$listener) {
49-
if (!$lazy || !$listenerinstanceofAbstractListener) {
49+
if (!$lazy || !$listenerinstanceofFirewallListenerInterface) {
5050
$listeners[] =$listener;
51-
$lazy =$lazy &&$listenerinstanceofAbstractListener;
51+
$lazy =$lazy &&$listenerinstanceofFirewallListenerInterface;
5252
}elseif (false !==$supports =$listener->supports($request)) {
5353
$listeners[] = [$listener,'authenticate'];
5454
$lazy =null ===$supports;

‎src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Compiler/SortFirewallListenersPassTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
useSymfony\Component\DependencyInjection\Argument\IteratorArgument;
1818
useSymfony\Component\DependencyInjection\ContainerBuilder;
1919
useSymfony\Component\DependencyInjection\Reference;
20+
useSymfony\Component\HttpFoundation\Request;
21+
useSymfony\Component\HttpKernel\Event\RequestEvent;
2022
useSymfony\Component\Security\Http\Firewall\FirewallListenerInterface;
2123

2224
class SortFirewallListenersPassTestextends TestCase
@@ -59,6 +61,14 @@ public function testSortFirewallListeners()
5961

6062
class FirewallListenerPriorityMinus1implements FirewallListenerInterface
6163
{
64+
publicfunctionsupports(Request$request): ?bool
65+
{
66+
}
67+
68+
publicfunctionauthenticate(RequestEvent$event)
69+
{
70+
}
71+
6272
publicstaticfunctiongetPriority():int
6373
{
6474
return -1;
@@ -67,6 +77,14 @@ public static function getPriority(): int
6777

6878
class FirewallListenerPriority1implements FirewallListenerInterface
6979
{
80+
publicfunctionsupports(Request$request): ?bool
81+
{
82+
}
83+
84+
publicfunctionauthenticate(RequestEvent$event)
85+
{
86+
}
87+
7088
publicstaticfunctiongetPriority():int
7189
{
7290
return1;
@@ -75,6 +93,14 @@ public static function getPriority(): int
7593

7694
class FirewallListenerPriority2implements FirewallListenerInterface
7795
{
96+
publicfunctionsupports(Request$request): ?bool
97+
{
98+
}
99+
100+
publicfunctionauthenticate(RequestEvent$event)
101+
{
102+
}
103+
78104
publicstaticfunctiongetPriority():int
79105
{
80106
return2;

‎src/Symfony/Component/Security/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ CHANGELOG
1414
* Added a CurrentUser attribute to force the UserValueResolver to resolve an argument to the current user.
1515
* Added`LoginThrottlingListener`.
1616
* Added`LoginLinkAuthenticator`.
17+
* Moved methods`supports()` and`authenticate()` from`AbstractListener` to`FirewallListenerInterface`.
1718

1819
5.1.0
1920
-----

‎src/Symfony/Component/Security/Http/Authentication/AuthenticatorManagerInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
useSymfony\Component\HttpFoundation\Request;
1515
useSymfony\Component\HttpFoundation\Response;
16-
useSymfony\Component\Security\Http\Firewall\AbstractListener;
16+
useSymfony\Component\Security\Http\Firewall\FirewallListenerInterface;
1717

1818
/**
1919
* @author Wouter de Jong <wouter@wouterj.nl>
@@ -26,7 +26,7 @@ interface AuthenticatorManagerInterface
2626
/**
2727
* Called to see if authentication should be attempted on this request.
2828
*
29-
* @seeAbstractListener::supports()
29+
* @seeFirewallListenerInterface::supports()
3030
*/
3131
publicfunctionsupports(Request$request): ?bool;
3232

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

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespaceSymfony\Component\Security\Http\Firewall;
1313

14-
useSymfony\Component\HttpFoundation\Request;
1514
useSymfony\Component\HttpKernel\Event\RequestEvent;
1615

1716
/**
@@ -28,18 +27,6 @@ final public function __invoke(RequestEvent $event)
2827
}
2928
}
3029

31-
/**
32-
* Tells whether the authenticate() method should be called or not depending on the incoming request.
33-
*
34-
* Returning null means authenticate() can be called lazily when accessing the token storage.
35-
*/
36-
abstractpublicfunctionsupports(Request$request): ?bool;
37-
38-
/**
39-
* Does whatever is required to authenticate the request, typically calling $event->setResponse() internally.
40-
*/
41-
abstractpublicfunctionauthenticate(RequestEvent$event);
42-
4330
publicstaticfunctiongetPriority():int
4431
{
4532
return0;// Default

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

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,30 @@
1111

1212
namespaceSymfony\Component\Security\Http\Firewall;
1313

14+
useSymfony\Component\HttpFoundation\Request;
15+
useSymfony\Component\HttpKernel\Event\RequestEvent;
16+
1417
/**
15-
* Can be implemented by firewall listeners to define their priority in execution.
18+
* Can be implemented by firewall listeners.
1619
*
1720
* @author Christian Scheb <me@christianscheb.de>
21+
* @author Nicolas Grekas <p@tchwork.com>
22+
* @author Robin Chalas <robin.chalas@gmail.com>
1823
*/
1924
interface FirewallListenerInterface
2025
{
26+
/**
27+
* Tells whether the authenticate() method should be called or not depending on the incoming request.
28+
*
29+
* Returning null means authenticate() can be called lazily when accessing the token storage.
30+
*/
31+
publicfunctionsupports(Request$request): ?bool;
32+
33+
/**
34+
* Does whatever is required to authenticate the request, typically calling $event->setResponse() internally.
35+
*/
36+
publicfunctionauthenticate(RequestEvent$event);
37+
2138
/**
2239
* Defines the priority of the listener.
2340
* The higher the number, the earlier a listener is executed.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp