10000 [Security] Fix resetting traceable listeners by chalasr · Pull Request #51858 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Security] Fix resetting traceable listeners #51858

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\Security\Http\Authenticator\Debug\TraceableAuthenticatorManagerListener;
use Symfony\Component\Security\Http\Firewall\FirewallListenerInterface;
use Symfony\Contracts\Service\ResetInterface;

/**
* Firewall collecting called security listeners and authenticators.
*
* @author Robin Chalas <robin.chalas@gmail.com>
*/
final class TraceableFirewallListener extends FirewallListener
final class TraceableFirewallListener extends FirewallListener implements ResetInterface
{
private $wrappedListeners = [];
private $authenticatorsInfo = [];
Expand All @@ -38,6 +39,12 @@ public function getAuthenticatorsInfo(): array
return $this->authenticatorsInfo;
}

public function reset(): void
{
$this->wrappedListeners = [];
$this->authenticatorsInfo = [];
}

protected function callListeners(RequestEvent $event, iterable $listeners)
{
$wrappedListeners = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,7 @@ private function createFirewall(ContainerBuilder $container, string $id, array $
->register('debug.security.firewall.authenticator.'.$id, TraceableAuthenticatorManagerListener::class)
->setDecoratedService('security.firewall.authenticator.'.$id)
->setArguments([new Reference('debug.security.firewall.authenticator.'.$id.'.inner')])
->addTag('kernel.reset', ['method' => 'reset'])
;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
service('security.logout_url_generator'),
])
->tag('kernel.event_subscriber')
->tag('kernel.reset', ['method' => 'reset'])
->alias('security.firewall', 'debug.security.firewall')
;
};
3 changes: 2 additions & 1 deletion src/Symfony/Bundle/SecurityBundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
"symfony/security-core": "^5.4|^6.0",
"symfony/security-csrf": "^4.4|^5.0|^6.0",
"symfony/security-guard": "^5.3",
"symfony/security-http": "^5.4.20|~6.0.20|~6.1.12|^6.2.6"
"symfony/security-http": "^5.4.30|^6.3.6",
"symfony/service-contracts": "^1.10|^2|^3"
},
"require-dev": {
"doctrine/annotations": "^1.10.4|^2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@
use Symfony\Component\Security\Http\Firewall\AbstractListener;
use Symfony\Component\Security\Http\Firewall\AuthenticatorManagerListener;
use Symfony\Component\VarDumper\Caster\ClassStub;
use Symfony\Contracts\Service\ResetInterface;

/**
* Decorates the AuthenticatorManagerListener to collect information about security authenticators.
*
* @author Robin Chalas <robin.chalas@gmail.com>
*/
final class TraceableAuthenticatorManagerListener extends AbstractListener
final class TraceableAuthenticatorManagerListener extends AbstractListener implements ResetInterface
{
private $authenticationManagerListener;
private $authenticatorsInfo = [];
Expand Down Expand Up @@ -78,4 +79,9 @@ public function getAuthenticatorsInfo(): array
{
return $this->authenticatorsInfo;
}

public function reset(): void
{
$this->authenticatorsInfo = [];
}
}
5 changes: 3 additions & 2 deletions src/Symfony/Component/Security/Http/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@
"require": {
"php": ">=7.2.5",
"symfony/deprecation-contracts": "^2.1|^3",
"symfony/security-core": "^5.4.19|~6.0.19|~6.1.11|^6.2.5",
"symfony/http-foundation": "^5.3|^6.0",
"symfony/http-kernel": "^5.3|^6.0",
"symfony/polyfill-mbstring": "~1.0",
"symfony/polyfill-php80": "^1.16",
"symfony/property-access": "^4.4|^5.0|^6.0"
"symfony/property-access": "^4.4|^5.0|^6.0",
"symfony/security-core": "^5.4.19|~6.0.19|~6.1.11|^6.2.5",
"symfony/service-contracts": "^1.10|^2|^3"
},
"require-dev": {
"symfony/cache": "^4.4|^5.0|^6.0",
Expand Down
0