You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feature symfony#41406 [Security] Add a method in the security helper to ease programmatic logout (johnkrovitch, chalasr)
This PR was merged into the 6.2 branch.
Discussion
----------
[Security] Add a method in the security helper to ease programmatic logout
| Q | A
| ------------- | ---
| Branch? | 6.x
| Bug fix? | no
| New feature? | yes
| Deprecations? | no
| Tickets | Fixsymfony#40663
| License | MIT
| Doc PR |
This PR aims to ease the programmatic login using the Security helper, to fix (symfony#40663).
A simple method has been added to the Security helper.
Thanks !
Commits
-------
e5e7d5e Make CSRF validation opt-in
f41a184 Add CSRF protection
f576173 [Security] Add a method in the security helper to ease programmatic logout (symfony#40663)
if (!$firewallConfig = $this->container->get('security.firewall.map')->getFirewallConfig($request)) {
90
+
thrownewLogicException('Unable to logout as the request is not behind a firewall.');
91
+
}
92
+
93
+
if ($validateCsrfToken) {
94
+
if (!$this->container->has('security.csrf.token_manager') || !$logoutConfig = $firewallConfig->getLogout()) {
95
+
thrownewLogicException(sprintf('Unable to logout with CSRF token validation. Either make sure that CSRF protection is enabled and "logout" is configured on the "%s" firewall, or bypass CSRF token validation explicitly by passing false to the $validateCsrfToken argument of this method.', $firewallConfig->getName()));
0 commit comments