Skip to content

Commit 6df01fe

Browse files
jimmyhealervmcj
authored andcommitted
Conditionally set WWW-Authenticate header for AJAX requests
1 parent e1f78ca commit 6df01fe

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

webapp/src/Security/DOMJudgeBasicAuthenticator.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,11 @@ public function onAuthenticationFailure(Request $request, AuthenticationExceptio
6767
// Otherwise, we pass along to the next authenticator.
6868
if ($exception instanceof BadCredentialsException || $exception instanceof UserNotFoundException) {
6969
$resp = new Response('', Response::HTTP_UNAUTHORIZED);
70-
$resp->headers->set('WWW-Authenticate', sprintf('Basic realm="%s"', 'Secured Area'));
70+
71+
if (!$request->isXmlHttpRequest()) {
72+
$resp->headers->set('WWW-Authenticate', sprintf('Basic realm="%s"', 'Secured Area'));
73+
}
74+
7175
return $resp;
7276
}
7377

0 commit comments

Comments
 (0)