Skip to content

Commit 77872ba

Browse files
committed
[SecurityBundle] Improve authenticators tab
1 parent 1a16ebc commit 77872ba

File tree

2 files changed

+124
-42
lines changed

2 files changed

+124
-42
lines changed

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

Lines changed: 118 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -29,24 +29,57 @@
2929
padding: 0 0 8px 0;
3030
}
3131
32+
#collector-content .authenticator-name {
33+
align-items: center;
34+
display: flex;
35+
gap: 16px;
36+
}
37+
38+
#collector-content .authenticators .toggle-button {
39+
margin-left: 0;
40+
}
41+
#collector-content .authenticators .sf-toggle-on .toggle-button {
42+
transform: rotate(180deg);
43+
}
44+
#collector-content .authenticators .toggle-button svg {
45+
display: block;
46+
}
47+
48+
#collector-content .authenticators th,
49+
#collector-content .authenticators td {
50+
vertical-align: baseline;
51+
}
52+
#collector-content .authenticators th,
53+
#collector-content .authenticators td {
54+
vertical-align: baseline;
55+
}
56+
57+
#collector-content .authenticators .label {
58+
display: block;
59+
text-align: center;
60+
}
61+
62+
#collector-content .authenticator-data {
63+
box-shadow: none;
64+
margin: 0;
65+
}
66+
67+
#collector-content .authenticator-data tr:first-child th,
68+
#collector-content .authenticator-data tr:first-child td {
69+
border-top: 0;
70+
}
71+
3272
#collector-content .authenticators .badge {
3373
color: var(--white);
3474
display: inline-block;
35-
text-align: center;
75+
margin: 4px 0;
3676
}
3777
#collector-content .authenticators .badge.badge-resolved {
3878
background-color: var(--green-500);
3979
}
4080
#collector-content .authenticators .badge.badge-not_resolved {
4181
background-color: var(--yellow-500);
4282
}
43-
44-
#collector-content .authenticators svg[data-icon-name="icon-tabler-check"] {
45-
color: var(--green-500);
46-
}
47-
#collector-content .authenticators svg[data-icon-name="icon-tabler-x"] {
48-
color: var(--red-500);
49-
}
5083
</style>
5184
{% endblock %}
5285

@@ -355,48 +388,91 @@
355388
<div class="tab-content">
356389
{% if collector.authenticators|default([]) is not empty %}
357390
<table class="authenticators">
391+
<colgroup>
392+
<col>
393+
<col style="width: 100%">
394+
</colgroup>
358395
<thead>
359396
<tr>
397+
<th>Status</th>
360398
<th>Authenticator</th>
361-
<th>Supports</th>
362-
<th>Authenticated</th>
363-
<th>Duration</th>
364-
<th>Passport</th>
365-
<th>Badges</th>
366399
</tr>
367400
</thead>
368-
369-
{% set previous_event = (collector.listeners|first) %}
370-
{% for authenticator in collector.authenticators %}
371-
{% if loop.first or authenticator != previous_event %}
372-
{% if not loop.first %}
373-
</tbody>
374-
{% endif %}
375-
376-
<tbody>
377-
{% set previous_event = authenticator %}
378-
{% endif %}
379-
380-
<tr>
381-
<td class="font-normal">{{ profiler_dump(authenticator.stub) }}</td>
382-
<td class="no-wrap">{{ source('@WebProfiler/Icon/' ~ (authenticator.supports is same as (false) ? 'no' : 'yes') ~ '.svg') }}</td>
383-
<td class="no-wrap">{{ authenticator.authenticated is not null ? source('@WebProfiler/Icon/' ~ (authenticator.authenticated ? 'yes' : 'no') ~ '.svg') : '' }}</td>
384-
<td class="no-wrap">{{ authenticator.duration is null ? '(none)' : '%0.2f ms'|format(authenticator.duration * 1000) }}</td>
385-
<td class="font-normal">{{ authenticator.passport ? profiler_dump(authenticator.passport) : '(none)' }}</td>
386-
<td class="font-normal">
387-
{% for badge in authenticator.badges ?? [] %}
388-
<span class="badge badge-{{ badge.resolved ? 'resolved' : 'not_resolved' }}">
389-
{{ badge.stub|abbr_class }}
390-
</span>
401+
{% for i, authenticator in collector.authenticators %}
402+
<tr class="sf-toggle"
403+
data-toggle-selector="#authenticator-{{ i }}"
404+
data-toggle-initial="{{ authenticator.authenticated is not null ? 'display' }}"
405+
aria-owns="authenticator-{{ i }}"
406+
>
407+
<td class="font-normal text-small">
408+
{% if authenticator.authenticated %}
409+
{% set status_text, label_status = 'success', 'success' %}
410+
{% elseif authenticator.authenticated is null %}
411+
{% set status_text, label_status = 'skipped', false %}
391412
{% else %}
392-
(none)
393-
{% endfor %}
413+
{% set status_text, label_status = 'failure', 'error' %}
414+
{% endif %}
415+
<span class="label {{ label_status ? 'status-' ~ label_status }}">{{ status_text }}</span>
416+
</td>
417+
<td>
418+
<span class="authenticator-name">
419+
{{ profiler_dump(authenticator.stub) }}
420+
<button class="btn btn-link toggle-button" type="button" style="margin-left: auto;">
421+
{{ source('@WebProfiler/Icon/chevron-down.svg') }}
422+
</button>
423+
</span>
424+
<div id="authenticator-{{ i }}">
425+
{% if authenticator.supports is same as(false) %}
426+
<div class="empty">
427+
<p>This authenticator did not support the request.</p>
428+
</div>
429+
{% elseif authenticator.authenticated is null %}
430+
<div class="empty">
431+
<p>An authenticator ran before this one.</p>
432+
</div>
433+
{% else %}
434+
<table class="authenticator-data">
435+
<colgroup>
436+
<col>
437+
<col width="100%">
438+
</colgroup>
439+
<tr>
440+
<th>Lazy</th>
441+
<td>{{ authenticator.supports is null ? 'yes' : 'no' }}</td>
442+
</tr>
443+
<tr>
444+
<th>Duration</th>
445+
<td>{{ '%0.2f ms'|format(authenticator.duration * 1000) }}</td>
446+
</tr>
447+
{% if authenticator.passport %}
448+
<tr>
449+
<th>Passport</th>
450+
<td>{{ profiler_dump(authenticator.passport) }}</td>
451+
</tr>
452+
{% endif %}
453+
{% if authenticator.badges %}
454+
<tr>
455+
<th>Badges</th>
456+
<td>
457+
{% for badge in authenticator.badges %}
458+
<span class="badge badge-{{ badge.resolved ? 'resolved' : 'not_resolved' }}">
459+
{{ badge.stub|abbr_class }}
460+
</span>
461+
{% endfor %}
462+
</td>
463+
</tr>
464+
{% endif %}
465+
{% if authenticator.exception %}
466+
<tr>
467+
<th>Exception</th>
468+
<td>{{ profiler_dump(authenticator.exception) }}</td>
469+
</tr>
470+
{% endif %}
471+
</table>
472+
{% endif %}
473+
</div>
394474
</td>
395475
</tr>
396-
397-
{% if loop.last %}
398-
</tbody>
399-
{% endif %}
400476
{% endfor %}
401477
</table>
402478
{% else %}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ final class TraceableAuthenticator implements AuthenticatorInterface, Interactiv
3535
private ?float $duration = null;
3636
private ClassStub|string $stub;
3737
private ?bool $authenticated = null;
38+
private ?AuthenticationException $exception = null;
3839

3940
public function __construct(private AuthenticatorInterface $authenticator)
4041
{
@@ -57,6 +58,7 @@ static function (BadgeInterface $badge): array {
5758
},
5859
$this->passport?->getBadges() ?? [],
5960
),
61+
'exception' => $this->exception,
6062
];
6163
}
6264

@@ -92,6 +94,10 @@ public function onAuthenticationSuccess(Request $request, TokenInterface $token,
9294
public function onAuthenticationFailure(Request $request, AuthenticationException $exception): ?Response
9395
{
9496
$this->authenticated = false;
97+
$this->exception = $exception->getPrevious() instanceof AuthenticationException
98+
? $exception->getPrevious()
99+
: $exception
100+
;
95101

96102
return $this->authenticator->onAuthenticationFailure($request, $exception);
97103
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy