8000 [DX] Added a logout link in the security panel of the web debug toolbar · symfony/symfony@192523a · GitHub
[go: up one dir, main page]

Skip to content
Sign in
Appearance settings

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

Commit 192523a

Browse files
javiereguiluzfabpot
authored andcommitted
[DX] Added a logout link in the security panel of the web debug toolbar
1 parent 317d30b commit 192523a

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/Symfony/Bundle/SecurityBundle/DataCollector/SecurityDataCollector.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public function collect(Request $request, Response $response, \Exception $except
5050
'enabled' => false,
5151
'authenticated' => false,
5252
'token_class' => null,
53+
'provider_key' => null,
5354
'user' => '',
5455
'roles' => array(),
5556
'inherited_roles' => array(),
@@ -60,6 +61,7 @@ public function collect(Request $request, Response $response, \Exception $except
6061
'enabled' => true,
6162
'authenticated' => false,
6263
'token_class' => null,
64+
'provider_key' => null,
6365
'user' => '',
6466
'roles' => array(),
6567
'inherited_roles' => array(),
@@ -80,6 +82,7 @@ public function collect(Request $request, Response $response, \Exception $except
8082
'enabled' => true,
8183
'authenticated' => $token->isAuthenticated(),
8284
'token_class' => get_class($token),
85+
'provider_key' => method_exists($token, 'getProviderKey') ? $token->getProviderKey() : null,
8386
'user' => $token->getUsername(),
8487
'roles' => array_map(function (RoleInterface $role) { return $role->getRole();}, $assignedRoles),
8588
'inherited_roles' => array_map(function (RoleInterface $role) { return $role->getRole(); }, $inheritedRoles),
@@ -159,6 +162,16 @@ public function getTokenClass()
159162
return $this->data['token_class'];
160163
}
161164

165+
/**
166+
* Get the provider key (i.e. the name of the active firewall).
167+
*
168+
* @return string The provider key
169+
*/
170+
public function getProviderKey()
171+
{
172+
return $this->data['provider_key'];
173+
}
174+
162175
/**
163176
* {@inheritdoc}
164177
*/

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@
3131
<span>{{ collector.tokenClass|abbr_class }}</span>
3232
</div>
3333
{% endif %}
34+
{% if collector.providerKey %}
35+
<div class="sf-toolbar-info-piece">
36+
<b>Actions</b>
37+
<span><a href="{{ logout_path(collector.providerKey) }}">Logout</a></span>
38+
</div>
39+
{% endif %}
3440
{% elseif collector.enabled %}
3541
<div class="sf-toolbar-info-piece">
3642
<span>You are not authenticated.</span>

0 commit comments

Comments
 (0)
0