Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f04a2f1

Browse files
committed
feature #41874 [SecurityBundle] Hide security toolbar if no firewall matched (wouterj)
This PR was merged into the 5.4 branch. Discussion ---------- [SecurityBundle] Hide security toolbar if no firewall matched | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #41242 (comment) | License | MIT | Doc PR | - As reported by `@pavol`-tk, we currently show a red Security block in the toolbar if no firewall matched. I think we should instead leave the block out of the toolbar, just like we do with all other elements if there is no data for that request. cc `@javiereguiluz` as you're the best in these UX like decisions :) Commits ------- 75590aa [SecurityBundle] Hide Security item if no firewall matched
2 parents d3757a1 + 75590aa commit f04a2f1

File tree

1 file changed

+66
-64
lines changed

1 file changed

+66
-64
lines changed

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

Lines changed: 66 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -3,85 +3,87 @@
33
{% block page_title 'Security' %}
44

55
{% block toolbar %}
6-
{% if collector.token %}
7-
{% set is_authenticated = collector.enabled and collector.authenticated %}
8-
{% set color_code = is_authenticated ? '' : 'yellow' %}
9-
{% elseif collector.enabled %}
10-
{% set color_code = collector.authenticatorManagerEnabled ? 'yellow' : 'red' %}
11-
{% else %}
12-
{% set color_code = '' %}
13-
{% endif %}
14-
15-
{% set icon %}
16-
{{ include('@Security/Collector/icon.svg') }}
17-
<span class="sf-toolbar-value">{{ collector.user|default('n/a') }}</span>
18-
{% endset %}
19-
20-
{% set text %}
21-
{% if collector.impersonated %}
22-
<div class="sf-toolbar-info-group">
23-
<div class="sf-toolbar-info-piece">
24-
<b>Impersonator</b>
25-
<span>{{ collector.impersonatorUser }}</span>
26-
</div>
27-
</div>
6+
{% if not collector.firewall %}
7+
{% if collector.token %}
8+
{% set is_authenticated = collector.enabled and collector.authenticated %}
9+
{% set color_code = is_authenticated ? '' : 'yellow' %}
10+
{% elseif collector.enabled %}
11+
{% set color_code = collector.authenticatorManagerEnabled ? 'yellow' : 'red' %}
12+
{% else %}
13+
{% set color_code = '' %}
2814
{% endif %}
2915

30-
<div class="sf-toolbar-info-group">
31-
{% if collector.enabled %}
32-
{% if collector.token %}
33-
<div class="sf-toolbar-info-piece">
34-
<b>Logged in as</b>
35-
<span>{{ collector.user }}</span>
36-
</div>
16+
{% set icon %}
17+
{{ include('@Security/Collector/icon.svg') }}
18+
<span class="sf-toolbar-value">{{ collector.user|default('n/a') }}</span>
19+
{% endset %}
3720

21+
{% set text %}
22+
{% if collector.impersonated %}
23+
<div class="sf-toolbar-info-group">
3824
<div class="sf-toolbar-info-piece">
39-
<b>Authenticated</b>
40-
<span class="sf-toolbar-status sf-toolbar-status-{{ is_authenticated ? 'green' : 'yellow' }}">{{ is_authenticated ? 'Yes' : 'No' }}</span>
25+
<b>Impersonator</b>
26+
<span>{{ collector.impersonatorUser }}</span>
4127
</div>
28+
</div>
29+
{% endif %}
4230

43-
<div class="sf-toolbar-info-piece">
44-
<b>Token class</b>
45-
<span>{{ collector.tokenClass|abbr_class }}</span>
46-
</div>
47-
{% else %}
48-
<div class="sf-toolbar-info-piece">
49-
<b>Authenticated</b>
50-
<span class="sf-toolbar-status sf-toolbar-status-yellow">No</span>
51-
</div>
52-
{% endif %}
31+
<div class="sf-toolbar-info-group">
32+
{% if collector.enabled %}
33+
{% if collector.token %}
34+
<div class="sf-toolbar-info-piece">
35+
<b>Logged in as</b>
36+
<span>{{ collector.user }}</span>
37+
</div>
38+
39+
<div class="sf-toolbar-info-piece">
40+
<b>Authenticated</b>
41+
<span class="sf-toolbar-status sf-toolbar-status-{{ is_authenticated ? 'green' : 'yellow' }}">{{ is_authenticated ? 'Yes' : 'No' }}</span>
42+
</div>
43+
44+
<div class="sf-toolbar-info-piece">
45+
<b>Token class</b>
46+
<span>{{ collector.tokenClass|abbr_class }}</span>
47+
</div>
48+
{% else %}
49+
<div class="sf-toolbar-info-piece">
50+
<b>Authenticated</b>
51+
<span class="sf-toolbar-status sf-toolbar-status-yellow">No</span>
52+
</div>
53+
{% endif %}
5354

54-
{% if collector.firewall %}
55-
<div class="sf-toolbar-info-piece">
56-
<b>Firewall name</b>
57-
<span>{{ collector.firewall.name }}</span>
58-
</div>
59-
{% endif %}
55+
{% if collector.firewall %}
56+
<div class="sf-toolbar-info-piece">
57+
<b>Firewall name</b>
58+
<span>{{ collector.firewall.name }}</span>
59+
</div>
60+
{% endif %}
6061

61-
{% if collector.token and collector.logoutUrl %}
62+
{% if collector.token and collector.logoutUrl %}
63+
<div class="sf-toolbar-info-piece">
64+
<b>Actions</b>
65+
<span>
66+
<a href="{{ collector.logoutUrl }}">Logout</a>
67+
{% if collector.impersonated and collector.impersonationExitPath %}
68+
| <a href="{{ collector.impersonationExitPath }}">Exit impersonation</a>
69+
{% endif %}
70+
</span>
71+
</div>
72+
{% endif %}
73+
{% else %}
6274
<div class="sf-toolbar-info-piece">
63-
<b>Actions</b>
64-
<span>
65-
<a href="{{ collector.logoutUrl }}">Logout</a>
66-
{% if collector.impersonated and collector.impersonationExitPath %}
67-
| <a href="{{ collector.impersonationExitPath }}">Exit impersonation</a>
68-
{% endif %}
69-
</span>
75+
<span>The security is disabled.</span>
7076
</div>
7177
{% endif %}
72-
{% else %}
73-
<div class="sf-toolbar-info-piece">
74-
<span>The security is disabled.</span>
75-
</div>
76-
{% endif %}
77-
</div>
78-
{% endset %}
78+
</div>
79+
{% endset %}
7980

80-
{{ include('@WebProfiler/Profiler/toolbar_item.html.twig', { link: profiler_url, status: color_code }) }}
81+
{{ include('@WebProfiler/Profiler/toolbar_item.html.twig', { link: profiler_url, status: color_code }) }}
82+
{% endif %}
8183
{% endblock %}
8284

8385
{% block menu %}
84-
<span class="label {{ not collector.enabled or not collector.token ? 'disabled' }}">
86+
<span class="label {{ not collector.firewall or not collector.token ? 'disabled' }}">
8587
<span class="icon">{{ include('@Security/Collector/icon.svg') }}</span>
8688
<strong>Security</strong>
8789
</span>

0 commit comments

Comments
 (0)