TapCub is live — analytics, insights and live chat, free on one platform
Glossary

What is basic authentication? How the header works and when to avoid it

Basic authentication sends a username and password in an HTTP header, Base64-encoded but not encrypted. How the header looks, how it compares with Bearer tokens and API keys, and what rate limiting changes.

Su He Reviewed by Ethan Brooks Also called basic auth Last updated Nov 19, 2026 Glossary

Quick answer

Basic authentication (HTTP Basic) is the simplest HTTP login scheme: the client sends Authorization: Basic followed by the Base64 of username:password with every request. Base64 is encoding, not encryption, so it is only acceptable over HTTPS and is a poor fit for user-facing sign-in.

Formula: Authorization: Basic base64(username + ":" + password)

What is basic authentication?

Basic authentication is the original HTTP login scheme, defined in RFC 7617. When a server wants proof of identity, it answers 401 Unauthorized with a WWW-Authenticate: Basic realm="..." header. The client then repeats the request with an Authorization header holding the word Basic and the Base64 of username:password. Browsers show a small login box; command-line tools and scripts just add the header.

The verdict in one paragraph: Basic authentication is encoding, not protection. It has no encryption, no expiry, no scope and no logout, so it is acceptable only over HTTPS, only for low-stakes or machine-to-machine access, and not for people signing in to a product. The rest of this page shows why, with a decoded header and the arithmetic of guessing.

The flow has three moves:

  1. The client requests a protected URL with no credentials.
  2. The server replies 401 with WWW-Authenticate: Basic realm="Staging". The realm is only a label for the protected area.
  3. The client resends the request with Authorization: Basic <credentials>, and does so again on every later request to that area, because HTTP itself keeps no session.

The credentials are built in two steps: join the user and password with a colon (username:password), then Base64-encode the whole string. One rule follows from the format: the user name cannot contain a colon, because the first colon in the string is the separator. The password can.

Worked example (sample data): RFC 7617's own pair, user Aladdin and password open sesame.

StepValue
Join with a colonAladdin:open sesame
Base64-encodeQWxhZGRpbjpvcGVuIHNlc2FtZQ==
Header sentAuthorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==

With curl the same thing is curl -u Aladdin:"open sesame" https://example.com/, and curl builds the header for you.

Is Base64 encryption?

No, and this is the most common misunderstanding. Base64 maps every 3 bytes to 4 printable characters. There is no key and no secret, so decoding is one function call. A second sample header, YWxpY2U6czNjcmV0LXBhc3M= (24 characters), decodes to alice:s3cret-pass. Anyone who sees that string in a proxy log, a browser extension, a screenshot or a packet capture has the password.

That is why RFC 7617 requires the connection itself to be protected: the scheme's only secrecy comes from TLS around it. Without HTTPS, every request exposes the password to every network device in between.

Basic vs Digest, Bearer, API key and session cookie

SchemeWhat is sent on each requestCan it expire or be limited?If it leaksTypical use
Basic (RFC 7617)The account's username and passwordNo, unless the password changesAttacker has the real password, possibly reused elsewhereStaging locks, simple internal services, some webhooks
Digest (RFC 7616)A hash computed from the password and a server challengeNoPassword is not sent, but old hashing choices are weakLegacy systems
Bearer token (RFC 6750)A token issued for the purposeYes: lifetime, scope, revocationAttacker has a token that can be revoked, not the passwordAPIs, OAuth 2.0 access tokens
API keyA long random string, usually in a headerBy design, if the provider supports rotation and scopesRevoke and reissue the keyServer-to-server calls
Session cookieAn opaque session id set after a login formYes: idle and absolute timeouts, logoutRevoke that sessionPeople signing in to a web product

The rule of thumb: if the thing being sent is the real password, a leak is expensive. If it is a separate credential that can be revoked, a leak is an incident you can close. API keys carry one extra warning: put them in a header, not in the URL, because URLs end up in server logs, browser history and referrer headers.

How risky is guessing, and what does rate limiting change?

Basic authentication has no built-in lockout, so protection depends on whatever sits in front of it. Rate limiting is that layer. The arithmetic below uses sample figures.

Password spaceGuesses to try everythingAt 100 requests/sAt 5 requests/minute (rate limited)
6-digit PIN10^6 = 1,000,00010,000 s ≈ 2.8 hours200,000 min ≈ 138.9 days
8 lowercase letters26^8 = 208,827,064,576about 66 yearsabout 79,500 years

Two cautions. First, the exhaustive figures are worst cases; on average an attacker succeeds after trying half of the space. Second, attackers rarely try everything: they try lists of leaked and common passwords first, so a short or reused password falls in minutes whatever the space looks like on paper. The lesson is that a long, random, unique password plus a request limit does the work, and the header format adds nothing.

Where Basic credentials leak

  • Logs. Servers and proxies that log request headers record the Authorization line. Mask it, and treat the log as holding passwords. A username can itself be personal data, so the same care applies.
  • URLs. Putting credentials in the address (https://user:pass@host/) puts them in history, bookmarks and referrer data. Use the header instead.
  • Browser caching and shared devices. Browsers keep Basic credentials for the session and have no real logout; closing every window is the only reset.
  • Screenshots and tickets. A pasted curl command or HAR file contains the header. Strip it before sharing.
  • Reused passwords. The password sent is the real one. If a staging password is also someone's work password, one log line is enough.

Who may see these logs, and how long they are kept, is a data governance decision; settle it before turning on header logging.

Common mistakes

  • Treating Base64 as protection ("it looks scrambled").
  • Using Basic over plain HTTP, even on an internal network.
  • One shared password for the whole team: no way to tell who did what, and every departure means a change for everybody.
  • Using it for customer sign-in instead of a session with lockout and multi-factor checks.
  • Never rotating the password because "nobody knows it" while it sits in old chat messages and scripts.
  • Counting a repeated 401 as harmless: a run of failed attempts against one URL is a guessing attempt and should trigger a limit.

Basic authentication and TapCub

TapCub does not provide, manage or proxy authentication for your site or API, and it has no Basic authentication interface. It only measures what happens on your pages. What you can do in practice:

  1. Do not send credentials as data. In All-platform analytics › Data › Tracking plan, write down each event's properties (name, type, description) and review the list for anything that looks like a password, token or Authorization value. Such fields do not belong in analytics.
  2. Know what is not recorded. Form auto-collection is off by default; when turned on it records only a form's id, name and action, not what was typed, so a login form's password field is never read.
  3. Check imported logs first. If you import web server logs through All-platform analytics › Data › Data import, make sure the log format does not include the Authorization header or URLs with embedded credentials.
  4. Use analytics to see who reaches a locked area. Status codes such as 401 need server collection or a log import; the page script alone does not see them.

TapCub does not rate-limit, block or authenticate traffic; for that, use your web server, gateway or CDN.

Sources

Was this explanation clear?

We use your answers to fix and expand this page.

Su He

Data Analyst

Explores traffic sources, conversion funnels, and retention, using clear metric definitions and concrete examples to explain what the numbers mean.

FAQ

Questions people ask

Short answers to the follow-up questions that come up most.

Still have a question?

Chat with the team behind TapCub — we usually reply within a few hours on business days.

Is basic authentication secure?

Only if the connection is HTTPS and the password is strong and rate-limited. The header carries the password on every request, and Base64 is trivially reversible, so anyone who can read the traffic or a log line can recover it. RFC 7617 requires TLS or an equivalent protection.

Is Base64 encryption?

No. Base64 is a reversible encoding that turns bytes into printable characters. It has no key, so anyone can decode it in one step. It exists so that a username, a colon and a password can travel safely inside a text header.

What is the difference between basic authentication and a Bearer token?

Basic sends the account's own username and password on every request. A Bearer token (RFC 6750) is a separate credential issued for a purpose, which can expire, carry limited scope and be revoked without changing the password.

When is basic authentication still acceptable?

For a quick lock on a staging site, a webhook receiver or an internal service reached only over HTTPS, with a long random password stored in a secret manager. It is not suitable for customer sign-in, where sessions, multi-factor checks and lockouts matter.

See this number on your own site

Add one script tag for web and apps, and the first reports fill in within minutes.

See your data clearly. Find your growth.

Every click, backed by data. Install one line of code and see your first numbers in a minute.

No credit card · Free plans for analytics and chat · Cookieless analytics