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/sessionAuthorization: Basic YWxpY2U6ZGVtbw==Authorization: Basic YWxpY2U6czNjcmV0 (decodes to alice:s3cret)Related terms
- Base64 — A way to write any bytes using only 64 safe text characters, so binary data can travel in places that expect text.
- Authorization header — The request header that carries a client’s credentials, such as Authorization: Bearer <token> or Authorization: Basic <encoded>.
- WWW-Authenticate — The response header sent with 401 Unauthorized that tells the client which authentication scheme to use, such as Basic or Bearer.
- bearer token — A token that grants access to whoever presents it, sent as Authorization: Bearer <token>, without any further proof of identity.
- HTTP — The protocol web browsers and web servers use to send requests and responses.
- TLS — The encryption that protects data travelling over a network, the S in HTTPS.
Taught in
- Basic Auth, Tokens And Sessions — Modern API Architecture: REST, GraphQL & gRPC
- Data States: Security at Rest, in Transit, and in Use — Cybersecurity Fundamentals, GRC & Cryptography