Skip to content

Commit 7d8c8e1

Browse files
committed
[Security] Display authenticators laziness and exception in the profiler
1 parent c0e30bb commit 7d8c8e1

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

src/Symfony/Bundle/SecurityBundle/Resources/views/Collector/security.html.twig

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,10 +340,12 @@
340340
<tr>
341341
<th>Authenticator</th>
342342
<th>Supports</th>
343+
<th>Lazy</th>
343344
<th>Authenticated</th>
344345
<th>Duration</th>
345346
<th>Passport</th>
346347
<th>Badges</th>
348+
<th>Exception</th>
347349
</tr>
348350
</thead>
349351

@@ -361,7 +363,8 @@
361363
<tr>
362364
<td class="font-normal">{{ profiler_dump(authenticator.stub) }}</td>
363365
<td class="no-wrap">{{ source('@WebProfiler/Icon/' ~ (authenticator.supports ? 'yes' : 'no') ~ '.svg') }}</td>
364-
<td class="no-wrap">{{ authenticator.authenticated is not null ? source('@WebProfiler/Icon/' ~ (authenticator.authenticated ? 'yes' : 'no') ~ '.svg') : '' }}</td>
366+
<td class="no-wrap">{{ authenticator.lazy is not null ? source('@WebProfiler/Icon/' ~ (authenticator.lazy ? 'yes' : 'no') ~ '.svg') }}</td>
367+
<td class="no-wrap">{{ authenticator.authenticated is not null ? source('@WebProfiler/Icon/' ~ (authenticator.authenticated ? 'yes' : 'no') ~ '.svg') }}</td>
365368
<td class="no-wrap">{{ authenticator.duration is null ? '(none)' : '%0.2f ms'|format(authenticator.duration * 1000) }}</td>
366369
<td class="font-normal">{{ authenticator.passport ? profiler_dump(authenticator.passport) : '(none)' }}</td>
367370
<td class="font-normal">
@@ -373,6 +376,7 @@
373376
(none)
374377
{% endfor %}
375378
</td>
379+
<td class="font-normal">{{ authenticator.exception ? profiler_dump(authenticator.exception) : '(none)' }}</td>
376380
</tr>
377381

378382
{% if loop.last %}

src/Symfony/Component/Security/Http/Authenticator/Debug/TraceableAuthenticator.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ final class TraceableAuthenticator implements AuthenticatorInterface, Interactiv
3434
private ?float $duration = null;
3535
private ClassStub|string $stub;
3636
private ?bool $authenticated = null;
37+
private ?bool $lazy = null;
38+
private ?AuthenticationException $exception = null;
3739

3840
public function __construct(private AuthenticatorInterface $authenticator)
3941
{
@@ -56,12 +58,18 @@ static function (BadgeInterface $badge): array {
5658
},
5759
$this->passport?->getBadges() ?? [],
5860
),
61+
'lazy' => $this->lazy,
62+
'exception' => $this->exception,
5963
];
6064
}
6165

6266
public function supports(Request $request): ?bool
6367
{
64-
return $this->authenticator->supports($request);
68+
$supports = $this->authenticator->supports($request);
69+
70+
$this->lazy = null === $supports;
71+
72+
return $supports;
6573
}
6674

6775
public function authenticate(Request $request): Passport
@@ -88,6 +96,7 @@ public function onAuthenticationSuccess(Request $request, TokenInterface $token,
8896
public function onAuthenticationFailure(Request $request, AuthenticationException $exception): ?Response
8997
{
9098
$this->authenticated = false;
99+
$this->exception = $exception->getPrevious() instanceof AuthenticationException ? $exception->getPrevious() : $exception;
91100

92101
return $this->authenticator->onAuthenticationFailure($request, $exception);
93102
}

src/Symfony/Component/Security/Http/Authenticator/Debug/TraceableAuthenticatorManagerListener.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ public function authenticate(RequestEvent $event): void
5555
'duration' => 0,
5656
'authenticated' => null,
5757
'badges' => [],
58+
'lazy' => null,
59+
'exception' => null,
5860
];
5961
}
6062

0 commit comments

Comments
 (0)