What is HTTP authentication?
Useful first: HTTP · optional, not a requirement
Choose your depth
Stay with the essentials, or look closer.
YOUR GOALSeparate proving an identity from being allowed to perform an action.
Show credentials, then check permission
A protected page can ask who you are
Imagine opening a members-only workshop manual. Before sending it, the server asks your browser or app to provide credentials: information it can check, such as an account name and password under an agreed authentication method.
HTTP authentication puts that conversation into request and response headers. The server announces a method, the client supplies the corresponding credentials, and the server evaluates the request. The HTTP guide explains the surrounding request and response exchange.
[1] [2]Identity and permission answer different questions
Suppose a workshop member may read the manual but only an editor may replace it. Recognizing the member does not give them the editor permission. Authentication checks the presented identity or credentials; authorization decides whether the requested action is allowed.
A useful analogy is showing a membership card at a desk. The card can identify a member without granting access to every room. The limit of the analogy is that software checks protocol data and access rules, not a physical card.
[1] [5]Proving who you are does not decide everything you may do.
Once a server recognizes my account, every action is allowed.
Valid credentials and permission are separate checks. A recognized account can still lack access to a particular action.
Show the explanation
Authentication can succeed while the account lacks permission for that action. The account can be recognized without having the editor permission required to replace the manual.
YOUR GOALInterpret the authentication headers and distinguish missing credentials from an access refusal.
Follow a challenge and read the outcome
Read the server challenge
For a protected manual, an initial request without valid credentials can receive these response headers:
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Basic realm="Workshop manuals"The 401 means this request lacks valid authentication credentials for the resource. It must include a challenge in WWW-Authenticate. Here, Basic names the authentication scheme, and the realm labels the protected area.
The client can retry with credentials in an Authorization request header. Sending that header is an attempt to authenticate, not proof that the server accepted it. These are illustrative headers, not instructions to enter a real password on this page.
Basic changes the encoding, not the secrecy
Basic builds its credential value from a username, a colon and a password, then Base64-encodes those bytes. For an invented username demo and password sample, the input is demo:sample.
The resulting value follows Basic in the Authorization header. Base64 can be decoded; it is not encryption and does not hide the password from someone who obtains that header. Use HTTPS to protect the connection carrying credentials.
Do not treat 401 and 403 as synonyms
- 401 Unauthorized: the request lacks valid credentials; inspect the challenge and the credentials used.
- 403 Forbidden: the server understands the request but refuses it. In the workshop example, a valid member account may lack editing permission.
Blindly repeating the same credentials is not a solution to missing permission. A 403 can also reflect a rule unrelated to credentials, so that status alone does not prove that login succeeded. Read the explanation and applicable access policy.
[4] [5] [7]Read the challenge, send appropriate credentials securely, and distinguish authentication from permission.
Base64 makes a Basic password unreadable to anyone who captures the header.
Base64 is reversible encoding. Transport protection must come from something such as HTTPS, not from the Basic encoding.
Show the explanation
The account lacks permission for this operation; resending the same credentials does not grant it. In this stated scenario the credentials were accepted, but the requested operation still requires a permission the account does not have.
YOUR GOALDistinguish origin and proxy authentication, scope credential reuse, and identify what HTTPS does not solve.
Keep credentials within the right boundary
The proxy and the destination ask different questions
An organizational forward proxy might require authentication before relaying requests to a documentation server. Its challenge uses:
HTTP/1.1 407 Proxy Authentication Required
Proxy-Authenticate: Basic realm="Workshop network"The client answers the proxy with Proxy-Authorization. If the destination also requires authentication, its separate exchange uses 401, WWW-Authenticate and Authorization. Passing the proxy check does not grant access to the destination.
Identify which component issued the challenge before selecting credentials. A website password and a proxy password are not interchangeable merely because both exchanges use HTTP.
[6] [7]A realm does not authorize reuse everywhere
A protection space is tied to the server origin and, when present, its realm. Two different servers displaying realm="Workshop manuals" do not thereby share an authentication boundary. Do not copy credentials to a different server just because the label matches.
Clients may reuse credentials within an applicable protection space, so a fresh 401 is not required before every authenticated request. The details depend on the authentication scheme. Other application login flows can instead pass session tokens in cookies; a login screen does not imply Basic authentication.
[7] [3]Transport protection has an endpoint
HTTPS protects the connection carrying Basic credentials, but the receiving endpoint still gets them. It does not prevent a dishonest destination from collecting a password or a server from storing password information unsafely. Basic over HTTPS is therefore not a complete account-security design.
Basic also has format rules: its challenge requires a realm, and a username cannot contain a colon because the first colon separates username from password. Non-ASCII credentials need compatible character encoding; the optional charset="UTF-8" challenge parameter addresses that issue. Encoding agreement and encrypted transport solve different problems.
Track who receives credentials, where they may be reused, and which protection each mechanism actually provides.
The same realm text on two servers makes it safe to reuse credentials automatically.
The origin is part of the protection boundary. Matching realm labels on different servers do not establish shared trust.
Show the explanation
Provide the appropriate proxy credentials in Proxy-Authorization; destination authentication may still be needed. 407 is a proxy challenge. Proxy-Authorization addresses that proxy; it does not replace the destination server's separate authentication and permission checks.
Keep asking. Check the details.
Source-checked using AI (OpenAI Codex) on . The checks covered sources, examples, and quizzes for this article version.
No human review is claimed. AI review can miss errors; check the original sources below.
- MDN — HTTP authentication
- MDN — WWW-Authenticate header
- MDN — Authorization header
- MDN — 401 Unauthorized
- MDN — 403 Forbidden
- MDN — 407 Proxy Authentication Required
- RFC 9110 — HTTP authentication and access control
- RFC 7617 — The Basic HTTP authentication scheme