Basic authentication

An HTTP authentication scheme that sends a user name and password in the Authorization header, joined with a colon and Base64-encoded.

The password is only encoded, so it is exposed if the connection or logs are.

In more detail

Base64 is encoding, not encryption, so anyone who sees the header can read the password: use it only over HTTPS and never log it. A missing or wrong password is answered with 401 and a WWW-Authenticate: Basic challenge.

Examples

In the APIs course: The course uses it once, to exchange a password for a short-lived token, rather than on every request.
curl -si -u alice:demo -X POST localhost:8765/session
Authorization: Basic YWxpY2U6ZGVtbw==
Authorization: Basic YWxpY2U6czNjcmV0  (decodes to alice:s3cret)

Related terms

Taught in

References