Skip to content

Commit 2a288db

Browse files
committed
bug #22584 [Security] Avoid unnecessary route lookup for empty logout path (ro0NL)
This PR was merged into the 2.7 branch. Discussion ---------- [Security] Avoid unnecessary route lookup for empty logout path | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no-ish | Deprecations? | no | Tests pass? | yes/no | Fixed tickets | #... <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | symfony/symfony-docs#... <!--highly recommended for new features--> i first included this with #22572 where having `logout: { path: ~ }` makes more sense for disabling logout path matching/generation. But currently it's already allowed and causes an unneeded route lookup and url generation. Commits ------- 2967807 [Security] Avoid unnecessary route lookup for empty logout path
2 parents 05240ce + 2967807 commit 2a288db

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/Symfony/Component/Security/Http/Firewall/LogoutListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,6 @@ public function handle(GetResponseEvent $event)
135135
*/
136136
protected function requiresLogout(Request $request)
137137
{
138-
return $this->httpUtils->checkRequestPath($request, $this->options['logout_path']);
138+
return isset($this->options['logout_path']) && $this->httpUtils->checkRequestPath($request, $this->options['logout_path']);
139139
}
140140
}

src/Symfony/Component/Security/Http/Logout/LogoutUrlGenerator.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@ private function generateLogoutUrl($key, $referenceType)
112112

113113
list($logoutPath, $csrfTokenId, $csrfParameter, $csrfTokenManager) = $this->listeners[$key];
114114

115+
if (null === $logoutPath) {
116+
throw new \LogicException('Unable to generate the logout URL without a path.');
117+
}
118+
115119
$parameters = null !== $csrfTokenManager ? array($csrfParameter => (string) $csrfTokenManager->getToken($csrfTokenId)) : array();
116120

117121
if ('/' === $logoutPath[0]) {

0 commit comments

Comments
 (0)