Skip to content

Navigation Menu

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

Appearance settings

[SecurityBundle] Do not replace authenticators service by their traceable version #59278

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
Dec 30, 2024
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 @@ -643,11 +643,13 @@ private function createAuthenticationListeners(ContainerBuilder $container, stri
}

if ($container->hasDefinition('debug.security.firewall')) {
foreach ($authenticationProviders as $authenticatorId) {
$container->register('debug.'.$authenticatorId, TraceableAuthenticator::class)
->setDecoratedService($authenticatorId)
->setArguments([new Reference('debug.'.$authenticatorId.'.inner')])
foreach ($authenticationProviders as &$authenticatorId) {
$traceableId = 'debug.'.$authenticatorId;
$container
->register($traceableId, TraceableAuthenticator::class)
->setArguments([new Reference($authenticatorId)])
;
$authenticatorId = $traceableId;
}
MatTheCat marked this conversation as resolved.
Show resolved Hide resolved
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
use Symfony\Component\DependencyInjection\Compiler\DecoratorServicePass;
use Symfony\Component\DependencyInjection\Compiler\ResolveChildDefinitionsPass;
use Symfony\Component\DependencyInjection\Compiler\ResolveReferencesToAliasesPass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\ExpressionLanguage\Expression;
Expand Down Expand Up @@ -900,6 +902,30 @@ public function testCustomHasherWithMigrateFrom()
]);
}

public function testAuthenticatorsDecoration()
{
$container = $this->getRawContainer();
$container->setParameter('kernel.debug', true);
$container->getCompilerPassConfig()->setOptimizationPasses([
new ResolveChildDefinitionsPass(),
new DecoratorServicePass(),
new ResolveReferencesToAliasesPass(),
]);

$container->register(TestAuthenticator::class);
$container->loadFromExtension('security', [
'firewalls' => ['main' => ['custom_authenticator' => TestAuthenticator::class]],
]);
$container->compile();

/** @var Reference[] $managerAuthenticators */
$managerAuthenticators = $container->getDefinition('security.authenticator.manager.main')->getArgument(0);
$this->assertCount(1, $managerAuthenticators);
$this->assertSame('debug.'.TestAuthenticator::class, (string) reset($managerAuthenticators), 'AuthenticatorManager must be injected traceable authenticators in debug mode.');

$this->assertTrue($container->hasDefinition(TestAuthenticator::class), 'Original authenticator must still exist in the container so it can be used outside of the AuthenticatorManager’s context.');
}

protected function getRawContainer()
{
$container = new ContainerBuilder();
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.