Course contentsShow
← Computer Science
Lesson 2499 of 2,87256. Authentication and AuthorizationFree lesson

Authentication Protocols: Basic Auth

Understand HTTP Basic Authentication, where credentials are sent encoded in headers with each request.

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

  1. Client requests a protected resource
  2. Server responds with 401 Unauthorized and a WWW-Authenticate: Basic realm="..." header
  3. Client prompts for credentials (if interactive) or uses stored ones
  4. Client sends credentials as Authorization: Basic <base64-encoded-username:password>
  5. Server decodes, validates, and grants or denies access
  6. 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.