Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP Basic Auth UnauthorizedHttpException not displaying login prompt #20883

Closed
ejunker opened this issue Aug 31, 2017 · 3 comments
Closed

HTTP Basic Auth UnauthorizedHttpException not displaying login prompt #20883

ejunker opened this issue Aug 31, 2017 · 3 comments

Comments

@ejunker
Copy link
Contributor

ejunker commented Aug 31, 2017

  • Laravel Version: 5.5.0
  • PHP Version: 7.1.4
  • Database Driver & Version: mysql 5.6.35

Description:

I have a middleware that calls onceBasic() to add password protection to a route. Prior to upgrading to 5.5 when I hit the route it would cause the browser to display the username/password dialog for HTTP Basic authentication. Now after upgrading to 5.5 I get a Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException and the Symfony exception handler renders an error page showing the exception. I believe this is related to this commit 37fb414 it is throwing an exception instead of a response and it looks like the exception is rendered by the exception handler instead of sending a 401 with the WWW-Authenticate: Basic header.

Steps To Reproduce:

@freekmurze
Copy link
Contributor

freekmurze commented Aug 31, 2017

I can confirm that basic auth is indeed broken as described above.

failedBasicResponse should return this:

 return new \Illuminate\Http\Response('Invalid credentials.', 401, ['WWW-Authenticate' => 'Basic']);

@ejunker Though I'm pretty sure this will be fixed at the framework level soon, you can fix this in your app by catching UnauthorizedHttpException in the exception handler. Here's an example from my app.

@DCzajkowski
Copy link
Contributor

No worries! I found the solution. PR in about 5 minutes

@ethernidee
Copy link

By unknown reason the code is the same again:

/**
 * Get the response for basic authentication.
 *
 * @return void
 *
 * @throws \Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException
 */
protected function failedBasicResponse()
{
    throw new UnauthorizedHttpException('Basic', 'Invalid credentials.');
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants