Skip to content

Commit 5b56a83

Browse files
MatTheCatfabpot
authored andcommitted
[Security] Display authenticators in the profiler even if they are all skipped
1 parent e7ff37b commit 5b56a83

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

Diff for: Command/DebugFirewallCommand.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
use Symfony\Component\Console\Style\SymfonyStyle;
2626
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
2727
use Symfony\Component\Security\Http\Authenticator\AuthenticatorInterface;
28+
use Symfony\Component\Security\Http\Authenticator\Debug\TraceableAuthenticator;
2829

2930
/**
3031
* @author Timo Bakx <[email protected]>
@@ -210,7 +211,7 @@ private function displayAuthenticators(string $name, SymfonyStyle $io): void
210211
$io->table(
211212
['Classname'],
212213
array_map(
213-
fn ($authenticator) => [$authenticator::class],
214+
fn ($authenticator) => [($authenticator instanceof TraceableAuthenticator ? $authenticator->getAuthenticator() : $authenticator)::class],
214215
$authenticators
215216
)
216217
);

Diff for: DependencyInjection/SecurityExtension.php

+10
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
use Symfony\Component\Security\Core\User\ChainUserProvider;
5959
use Symfony\Component\Security\Core\User\UserCheckerInterface;
6060
use Symfony\Component\Security\Core\User\UserProviderInterface;
61+
use Symfony\Component\Security\Http\Authenticator\Debug\TraceableAuthenticator;
6162
use Symfony\Component\Security\Http\Authenticator\Debug\TraceableAuthenticatorManagerListener;
6263
use Symfony\Component\Security\Http\Event\CheckPassportEvent;
6364
use Symfony\Flex\Command\InstallRecipesCommand;
@@ -638,6 +639,15 @@ private function createAuthenticationListeners(ContainerBuilder $container, stri
638639
}
639640
}
640641

642+
if ($container->hasDefinition('debug.security.firewall')) {
643+
foreach ($authenticationProviders as $authenticatorId) {
644+
$container->register('debug.'.$authenticatorId, TraceableAuthenticator::class)
645+
->setDecoratedService($authenticatorId)
646+
->setArguments([new Reference('debug.'.$authenticatorId.'.inner')])
647+
;
648+
}
649+
}
650+
641651
// the actual entry point is configured by the RegisterEntryPointPass
642652
$container->setParameter('security.'.$id.'._indexed_authenticators', $entryPoints);
643653

Diff for: Resources/views/Collector/security.html.twig

+1-1
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@
360360

361361
<tr>
362362
<td class="font-normal">{{ profiler_dump(authenticator.stub) }}</td>
363-
<td class="no-wrap">{{ source('@WebProfiler/Icon/' ~ (authenticator.supports ? 'yes' : 'no') ~ '.svg') }}</td>
363+
<td class="no-wrap">{{ source('@WebProfiler/Icon/' ~ (authenticator.supports is same as (false) ? 'no' : 'yes') ~ '.svg') }}</td>
364364
<td class="no-wrap">{{ authenticator.authenticated is not null ? source('@WebProfiler/Icon/' ~ (authenticator.authenticated ? 'yes' : 'no') ~ '.svg') : '' }}</td>
365365
<td class="no-wrap">{{ authenticator.duration is null ? '(none)' : '%0.2f ms'|format(authenticator.duration * 1000) }}</td>
366366
<td class="font-normal">{{ authenticator.passport ? profiler_dump(authenticator.passport) : '(none)' }}</td>

Diff for: Tests/Debug/TraceableFirewallListenerTest.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
2323
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
2424
use Symfony\Component\Security\Http\Authentication\AuthenticatorManager;
25+
use Symfony\Component\Security\Http\Authenticator\Debug\TraceableAuthenticator;
2526
use Symfony\Component\Security\Http\Authenticator\Debug\TraceableAuthenticatorManagerListener;
2627
use Symfony\Component\Security\Http\Authenticator\InteractiveAuthenticatorInterface;
2728
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge;
@@ -99,7 +100,7 @@ public function testOnKernelRequestRecordsAuthenticatorsInfo()
99100
$tokenStorage = $this->createMock(TokenStorageInterface::class);
100101
$dispatcher = new EventDispatcher();
101102
$authenticatorManager = new AuthenticatorManager(
102-
[$notSupportingAuthenticator, $supportingAuthenticator],
103+
[new TraceableAuthenticator($notSupportingAuthenticator), new TraceableAuthenticator($supportingAuthenticator)],
103104
$tokenStorage,
104105
$dispatcher,
105106
'main'

0 commit comments

Comments
 (0)