8000 [DX] Added a logout link in the security panel of the web debug toolbar by javiereguiluz · Pull Request #14378 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[DX] Added a logout link in the security panel of the web debug toolbar #14378

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public function collect(Request $request, Response $response, \Exception $except
'enabled' => false,
'authenticated' => false,
'token_class' => null,
'provider_key' => null,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not firewall key? sounds more natural

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. However, the method in the token is called getProviderKey(). That's why I prefer to be consistent here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok sounds cool then, now i agree 👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cordoval multiple firewalls can share the same authentication provider (using the context setting in the config). So the provider key may not be the firewall name.

'user' => '',
'roles' => array(),
'inherited_roles' => array(),
Expand All @@ -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(),
Expand All @@ -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),
Expand Down Expand Up @@ -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}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@
<span>{{ collector.tokenClass|abbr_class }}</span>
</div>
{% endif %}
{% if collector.providerKey %}
<div class="sf-toolbar-info-piece">
<b>Actions</b>
<span><a href="{{ logout_path(collector.providerKey) }}">Logout</a></span>
</div>
{% endif %}
{% elseif collector.enabled %}
<div class="sf-toolbar-info-piece">
<span>You are not authenticated.</span>
Expand Down
0