Authentication Protocols: Basic Auth
You'll learn how HTTP Basic Authentication transmits credentials with every request using simple base64 encoding.
What is HTTP Basic Authentication?
HTTP Basic Auth is one of the simplest authentication protocols built into the HTTP standard. When you access a protected resource, the server challenges you to provide credentials. Your browser or client then sends your username and password, encoded in base64, in the Authorization header with every subsequent request to that server.
Think of it like showing your ID card every single time you enter a building—even if the guard just saw you five minutes ago. There's no memory of your previous authentication; each request must prove itself independently.
How It Works
- Client requests a protected resource
- Server responds with
401 Unauthorizedand aWWW-Authenticate: Basic realm="..."header - Client prompts for credentials (if interactive) or uses stored ones
- Client sends credentials as
Authorization: Basic <base64-encoded-username:password> - Server decodes, validates, and grants or denies access
- Every future request repeats step 4
The encoding format is simply: base64(username:password). For example, admin:secret123 becomes YWRtaW46c2VjcmV0MTIz.
Critical Limitations
Basic Auth has serious security weaknesses:
- Base64 is encoding, not encryption—credentials are easily decoded
- Credentials travel with every request, increasing exposure
- No built-in logout mechanism (browser caches credentials)
- Must be used over HTTPS or credentials are sent in plaintext
This makes Basic Auth suitable only for simple internal tools, APIs over HTTPS, or as a quick development solution—never for production user-facing applications without TLS.
Key Takeaway: HTTP Basic Authentication sends base64-encoded credentials in the Authorization header with every request, making it simple but inherently insecure without HTTPS protection and unsuitable for most modern applications.