From 7071c9df530000df625849a0138ad6d62316e49e Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 16 Apr 2015 17:43:29 +0200 Subject: [PATCH 1/6] Added a logout link in the security panel of the web debug toolbar --- .../DataCollector/SecurityDataCollector.php | 13 +++++++++++++ .../Resources/views/Collector/security.html.twig | 5 +++++ 2 files changed, 18 insertions(+) diff --git a/src/Symfony/Bundle/SecurityBundle/DataCollector/SecurityDataCollector.php b/src/Symfony/Bundle/SecurityBundle/DataCollector/SecurityDataCollector.php index a6ea333d95b85..ec2afa6345712 100644 --- a/src/Symfony/Bundle/SecurityBundle/DataCollector/SecurityDataCollector.php +++ b/src/Symfony/Bundle/SecurityBundle/DataCollector/SecurityDataCollector.php @@ -50,6 +50,7 @@ public function collect(Request $request, Response $response, \Exception $except 'enabled' => false, 'authenticated' => false, 'token_class' => null, + 'provider_key' => null, 'user' => '', 'roles' => array(), 'inherited_roles' => array(), @@ -60,6 +61,7 @@ public function collect(Request $request, Response $response, \Exception $except 'enabled' => true, 'authenticated' => false, 'token_class' => null, + 'provider_key' => null, 'user' => '', 'roles' => array(), 'inherited_roles' => array(), @@ -80,6 +82,7 @@ public function collect(Request $request, Response $response, \Exception $except 'enabled' => true, 'authenticated' => $token->isAuthenticated(), 'token_class' => get_class($token), + 'provider_key' => method_exists($token, 'getProviderKey') ? $token->getProviderKey() : null, 'user' => $token->getUsername(), 'roles' => array_map(function (RoleInterface $role) { return $role->getRole();}, $assignedRoles), 'inherited_roles' => array_map(function (RoleInterface $role) { return $role->getRole(); }, $inheritedRoles), @@ -159,6 +162,16 @@ public function getTokenClass() return $this->data['token_class']; } + /** + * Get the provider key (i.e. the name of the active firewall). + * + * @return string The provider key + */ + public function getProviderKey() + { + return $this->data['provider_key']; + } + /** * {@inheritdoc} */ diff --git a/src/Symfony/Bundle/SecurityBundle/Resources/views/Collector/security.html.twig b/src/Symfony/Bundle/SecurityBundle/Resources/views/Collector/security.html.twig index 6c5b85356de1a..ba3b946a48828 100644 --- a/src/Symfony/Bundle/SecurityBundle/Resources/views/Collector/security.html.twig +++ b/src/Symfony/Bundle/SecurityBundle/Resources/views/Collector/security.html.twig @@ -31,6 +31,11 @@ {{ collector.tokenClass|abbr_class }} {% endif %} + {% if collector.providerKey != null %} +
+ Logout +
+ {% endif %} {% elseif collector.enabled %}
You are not authenticated. From 43a0c8a18cd1ed9e29e7af17341b1cd49eb48bc5 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 16 Apr 2015 17:50:15 +0200 Subject: [PATCH 2/6] Dummy commit to make fabbot analyze the PR again to remove the error --- .../SecurityBundle/Resources/views/Collector/security.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/SecurityBundle/Resources/views/Collector/security.html.twig b/src/Symfony/Bundle/SecurityBundle/Resources/views/Collector/security.html.twig index ba3b946a48828..c57a3388f16bd 100644 --- a/src/Symfony/Bundle/SecurityBundle/Resources/views/Collector/security.html.twig +++ b/src/Symfony/Bundle/SecurityBundle/Resources/views/Collector/security.html.twig @@ -33,7 +33,7 @@ {% endif %} {% if collector.providerKey != null %} {% endif %} {% elseif collector.enabled %} From 39fd133d1632b555e986d910f42655bea02ca296 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 16 Apr 2015 17:50:45 +0200 Subject: [PATCH 3/6] Dummy commit to make fabbot analyze the PR again to remove the error --- .../SecurityBundle/Resources/views/Collector/security.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/SecurityBundle/Resources/views/Collector/security.html.twig b/src/Symfony/Bundle/SecurityBundle/Resources/views/Collector/security.html.twig index c57a3388f16bd..ba3b946a48828 100644 --- a/src/Symfony/Bundle/SecurityBundle/Resources/views/Collector/security.html.twig +++ b/src/Symfony/Bundle/SecurityBundle/Resources/views/Collector/security.html.twig @@ -33,7 +33,7 @@ {% endif %} {% if collector.providerKey != null %} {% endif %} {% elseif collector.enabled %} From 73201365d197ae5c319c63f3f3d85efd2fe27dfa Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 16 Apr 2015 19:51:56 +0200 Subject: [PATCH 4/6] Further style tweaks --- .../Resources/views/Collector/security.html.twig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Bundle/SecurityBundle/Resources/views/Collector/security.html.twig b/src/Symfony/Bundle/SecurityBundle/Resources/views/Collector/security.html.twig index ba3b946a48828..9d3b019157cf0 100644 --- a/src/Symfony/Bundle/SecurityBundle/Resources/views/Collector/security.html.twig +++ b/src/Symfony/Bundle/SecurityBundle/Resources/views/Collector/security.html.twig @@ -31,9 +31,9 @@ {{ collector.tokenClass|abbr_class }}
{% endif %} - {% if collector.providerKey != null %} + {% if collector.providerKey %}
- Logout + × Logout
{% endif %} {% elseif collector.enabled %} From aef50966553aab4ef28d1c07f8f8e09cf8af9f65 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 24 Apr 2015 09:30:12 +0200 Subject: [PATCH 5/6] Tweaked again the button to logout from the application --- .../Resources/views/Collector/security.html.twig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/SecurityBundle/Resources/views/Collector/security.html.twig b/src/Symfony/Bundle/SecurityBundle/Resources/views/Collector/security.html.twig index 9d3b019157cf0..8a086c92ad3f8 100644 --- a/src/Symfony/Bundle/SecurityBundle/Resources/views/Collector/security.html.twig +++ b/src/Symfony/Bundle/SecurityBundle/Resources/views/Collector/security.html.twig @@ -33,7 +33,8 @@ {% endif %} {% if collector.providerKey %}
- × Logout + Actions + Logout
{% endif %} {% elseif collector.enabled %} From a8b0d3f7ed81794c34219c86ff898ba789f6f943 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Sat, 1 Aug 2015 17:14:31 +0200 Subject: [PATCH 6/6] Display the "logout" action as a link, not a button --- .../SecurityBundle/Resources/views/Collector/security.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/SecurityBundle/Resources/views/Collector/security.html.twig b/src/Symfony/Bundle/SecurityBundle/Resources/views/Collector/security.html.twig index 8a086c92ad3f8..3d68990f3610f 100644 --- a/src/Symfony/Bundle/SecurityBundle/Resources/views/Collector/security.html.twig +++ b/src/Symfony/Bundle/SecurityBundle/Resources/views/Collector/security.html.twig @@ -34,7 +34,7 @@ {% if collector.providerKey %}
Actions - Logout + Logout
{% endif %} {% elseif collector.enabled %}