Skip to content
Snippets Groups Projects
Commit 48f6e295 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2432657 by Berdir, znerol: BasicAuth challenge never sent to browser

parent d611ac4b
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -136,6 +136,7 @@ protected function onHtml(GetResponseForExceptionEvent $event) {
if ($exception instanceof HttpExceptionInterface) {
$response->setStatusCode($exception->getStatusCode());
$response->headers->add($exception->getHeaders());
}
else {
$response->setStatusCode(Response::HTTP_INTERNAL_SERVER_ERROR, '500 Service unavailable (with message)');
......@@ -166,6 +167,7 @@ protected function onJson(GetResponseForExceptionEvent $event) {
$response = new JsonResponse($data, Response::HTTP_INTERNAL_SERVER_ERROR);
if ($exception instanceof HttpExceptionInterface) {
$response->setStatusCode($exception->getStatusCode());
$response->headers->add($exception->getHeaders());
}
$event->setResponse($response);
......
......@@ -7,6 +7,7 @@
namespace Drupal\basic_auth\Tests\Authentication;
use Drupal\Component\Utility\String;
use Drupal\Core\Url;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\simpletest\WebTestBase;
......@@ -53,6 +54,7 @@ public function testBasicAuth() {
// @todo Change ->drupalGet() calls to just pass $url when
// https://www.drupal.org/node/2350837 gets committed
$this->drupalGet($url->setAbsolute()->toString());
$this->assertEqual($this->drupalGetHeader('WWW-Authenticate'), String::format('Basic realm="@realm"', ['@realm' => \Drupal::config('system.site')->get('name')]));
$this->assertResponse('401', 'Not authenticated on the route that allows only basic_auth. Prompt to authenticate received.');
$this->drupalGet('admin');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment