Basic access authentication

This example protects a part of the site with HTTP basic authentication. A guard checks the Authorization header of every request below /basic-auth/protected and answers with 401 and a WWW-Authenticate header if it is missing or wrong. Stylesheets are let through, so even the error page is styled.

Try it
  1. Open the protected area below.
  2. When your browser asks, enter demo as username and password.
  3. Or press "Cancel" to see the error page instead.

Browsers remember the credentials until they are closed, so you won't be asked twice.