SECTION 02 · 12 MIN READ & EXPLORE
Basic, without the mystery
Inspect the header, decode the credentials, and run a tiny protected server.
DEMONSTRATION CONTENTBasic authentication encodes username:password using Base64 and places it after the word Basic in the request’s Authorization header.
Authorization: Basic ZGVtbzpkZW1v
That value decodes to demo:demo. Base64 is an encoding, not encryption. Real credentials require a protected transport such as HTTPS.
Inspect a local authentication exchange
Use Docker with Compose installed. Make a directory and save these three files together: compose.yaml, nginx.conf, and .htpasswd. The credentials are deliberately public: demo / demo.
- Start the server from that directory:
docker compose up -d- Request the page without credentials:
curl -i http://localhost:8080/Expect 401 and a WWW-Authenticate: Basic challenge.
- Retry with the demo credentials:
curl -i -u demo:demo http://localhost:8080/Expect 200 and the Nginx welcome page. Change the password and predict the status before running the command again.
- Clean up when finished:
docker compose downThis lab uses plain HTTP on your machine’s loopback interface. Use only the supplied demonstration credentials.
Download compose.yamlTake a moment to explain the idea in your own words.