Skip to content

Commit 7a4fdf7

Browse files
committed
bug symfony#14593 [Security][Firewall] Avoid redirection to XHR URIs (asiragusa)
This PR was submitted for the 2.7 branch but it was merged into the 2.3 branch instead (closes symfony#14593). Discussion ---------- [Security][Firewall] Avoid redirection to XHR URIs | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | If `security.firewalls.main.form_login.always_use_default_target_path` is false, an user could be redirected to an URL called by an AJAX request after the login. Commits ------- 9ee74ea Avoid redirection to XHR URIs
2 parents 75ed3b1 + 9ee74ea commit 7a4fdf7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ private function startAuthentication(Request $request, AuthenticationException $
194194
protected function setTargetPath(Request $request)
195195
{
196196
// session isn't required when using HTTP basic authentication mechanism for example
197-
if ($request->hasSession() && $request->isMethodSafe()) {
197+
if ($request->hasSession() && $request->isMethodSafe() && !$request->isXmlHttpRequest()) {
198198
$request->getSession()->set('_security.'.$this->providerKey.'.target_path', $request->getUri());
199199
}
200200
}

0 commit comments

Comments
 (0)