HTTP Authentication Explore the methods02 / 04

SECTION 02 · 12 MIN READ & EXPLORE

Basic, without the mystery

Inspect the header, decode the credentials, and run a tiny protected server.

DEMONSTRATION CONTENT

Basic 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.

READ Focus on section 2

The Basic authentication scheme — RFC 7617 (opens in a new tab)

Read the construction of the credentials. Notice that the encoding does not protect the password, and look for the discussion of transport security.

HANDS-ON LAB 10 min

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.

  1. Start the server from that directory:
docker compose up -d
  1. Request the page without credentials:
curl -i http://localhost:8080/

Expect 401 and a WWW-Authenticate: Basic challenge.

  1. 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.

  1. Clean up when finished:
docker compose down

This lab uses plain HTTP on your machine’s loopback interface. Use only the supplied demonstration credentials.

Download compose.yaml
A LITTLE CLEARER?

Take a moment to explain the idea in your own words.

Progress is saved in this browser.

HTTP Authentication

Course overview ↗

01Understand the exchange

  1. Follow the request6m