Authentication vs Authorization in Web Applications

Authentication vs Authorization in Web Applications

Every web application has to answer two questions on every request – who is this, and what are they allowed to do? Mixing up authentication vs authorization causes some of the most damaging flaws in web application security, because a login screen that works perfectly says nothing about whether the right data reaches the right user. This article covers the difference between the two controls, where each one breaks in real codebases, and how to test both before an attacker does.

Authentication vs Authorization – The Core Distinction

Authentication proves identity. A user submits a password, a passkey, a TOTP code or a federated token from Google or Microsoft Entra ID, and the application decides whether to trust the claim “I am user 4812.”

Authorization decides what that verified identity may do. Can user 4812 read invoice 9930? Can they change another user’s email? Can they call the admin export endpoint?

The HTTP spec shows the difference too. A 401 Unauthorized response really means “not authenticated,” and a 403 Forbidden means “authenticated, but not allowed.” The naming is confusing and has been for decades, but the split behind it is clear.

Why Authorization Fails More Often

Authentication usually sits in one place: a login flow, a session middleware, an identity provider. Teams buy it or adopt it from a framework, and it gets reviewed heavily. Authorization is spread across hundreds of endpoints, and every new route is a new chance to forget a check.

That explains why Broken Access Control has topped the OWASP Top 10 since the 2021 edition, while authentication failures sit lower on the list. A single missing ownership check on one API route is enough.

Here’s a scenario any AppSec reviewer will recognize. A SaaS billing dashboard serves invoices at /api/invoices/{id}. The endpoint carries the framework’s @login_required decorator, so the code review passed. Nobody noticed that the query fetches the invoice by ID alone, with no filter on the requesting account. Any logged-in customer could step through IDs and download every other customer’s billing data. That is a textbook case of insecure direct object references, and it usually survives in production for months because nothing errors or looks broken.

A Common Myth: “Logged-In Users Are Trusted Users”

The most persistent misconception is that once authentication succeeds, the hard part is done. Many internal tools and B2B portals run on this assumption. Their reasoning is that every user is a paying customer or an employee, so they won’t misbehave.

In reality, a large share of serious access control abuse comes from authenticated accounts. Free trial signups, compromised customer credentials and curious employees all pass authentication. On a self-service SaaS, a strong login protects nothing if any stranger can register for a free trial and then reach other tenants’ data.

A related myth says JWTs handle authorization. A JWT carries claims, such as a role or a scope. It doesn’t enforce anything. The server still has to check those claims against the resource being requested, every time.

How to Test Both Controls Step by Step

An experienced penetration tester treats these as two separate test tracks. Authentication testing comes first, then authorization testing with at least two accounts at different privilege levels.

  1. Map every endpoint, including API routes the frontend calls in the background. Single page applications often expose 3-5 times more routes than the visible UI suggests.
  2. Test authentication on its own: session expiry, logout invalidation, password reset token reuse, MFA bypass via direct navigation, and rate limits on login.
  3. Create two users in different tenants (A and B) plus one admin. Capture requests as user A, then replay them with user B’s session.
  4. Replay admin requests with a low-privilege session, and replay everything with no session at all.
  5. Check write operations separately from reads. Teams often protect GET but forget PUT, PATCH and DELETE on the same resource.

Burp Suite’s Autorize extension automates step 3 well. It reissues every proxied request with a second user’s cookies and flags responses that match. For deeper reading on the login side, see the guide on how to detect and fix broken authentication.

Common Mistakes Practitioners Make

Enforcing authorization in the frontend. Hiding the “Delete user” button for non-admins is UX, not security. If the backend endpoint accepts the request, the control does not exist. This pattern shows up constantly in React and Vue apps where role checks live in components.

Trusting client-supplied identity fields. APIs that accept userId or role in a request body and act on it let a user grant themselves privileges. The identity must come from the server-side session or a verified token, never from the payload. The same applies to OAuth scopes – a broad read:all token issued to a third-party integration is an authorization decision made once and rarely revisited.

Relying on automated scanners alone for access control. A vulnerability scanner is good at finding missing security headers, weak SSL/TLS configurations, exposed admin panels and injection points like SQL injection or XSS. It can’t know that invoice 9930 belongs to tenant B. Ownership rules are business logic, and they need authenticated multi-user testing or code review.

Edge Cases Where Standard Advice Shifts

Teams under 10 people with an internal tool behind a VPN sometimes skip granular authorization entirely. That’s defensible only if every user really should see everything – and that stops being true the day a contractor or a customer support hire joins.

Single-tenant deployments reduce cross-tenant risk but not vertical privilege escalation. A viewer becoming an admin is still possible.

Regulated environments change the stakes. Under GDPR Article 32, an IDOR that exposes personal data is a reportable breach, with the 72-hour notification clock that comes with it. Healthcare and payment systems under HIPAA or PCI DSS 4.0 usually need documented access control testing, not just good intentions.

FAQ

Which comes first, authentication or authorization?
Authentication always comes first, because the system can’t decide what someone may do until it knows who they are. Some public resources need neither, and some endpoints authorize anonymous access deliberately.

Is OAuth 2.0 authentication or authorization?
OAuth 2.0 is an authorization framework – it delegates access through scoped tokens. OpenID Connect adds an identity layer on top of it for authentication. Using bare OAuth access tokens as proof of login is a known anti-pattern.

Can a vulnerability scanner find authorization flaws?
Partially. Scanners catch unauthenticated access to protected paths, exposed admin interfaces and misconfigurations. Horizontal access flaws between users usually need authenticated testing with multiple accounts or a manual security audit.

Key Takeaways for Development Teams

Authentication answers “who,” authorization answers “what,” and most real breaches happen in the gap between them. Put identity in one well-tested place, enforce authorization on the server for every route and every HTTP method, and derive ownership from the session, never from the request.

As a practical next step, take your five most sensitive endpoints this week and replay their requests with a second user’s session. It takes about an hour, and it’s often the fastest way to find a critical bug before someone else does.