6.16. Using Digest Versus Basic Authentication
Problem
You want to understand the distinction between the Basic and Digest authentication methods.
Solution
Use AuthType Basic and the
htpasswd tool to control access
using Basic authentication. Use
AuthType Digest and the
htdigest tool for the Digest method.
Discussion
Basic Web authentication is
exactly that: primitive and insecure. It works by encoding the user
credentials with a reversible algorithm (essentially base-64 encoding)
and transmitting the result in plaintext as part of the request
header. Anyone (or anything) that intercepts the transmission can
easily crack the encoding of the credentials and use them later. As a
consequence, Basic authentication
should only be used in environments where the protected documents
aren’t truly sensitive or when there is no alternative.
In contrast, Digest
authentication uses a more secure method that is much less susceptible to credential theft,
spoofing, and replay attacks. The exact details don’t matter; the
essential ingredient is that no username or password traverses the
network in plaintext.
Preparing a realm to use Basic authentication consists of simply
storing the username/password pair and telling the server where to
find them. The password may or may not be encrypted. The same
credentials may be applied to any realm on the server, or even copied
to a completely different server and used there. They may be stored in
a variety of databases; multiple modules exist for storing Basic
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access