Authentication vs Authorization: What Is the Difference?
Authentication checks who you are; authorization decides what you can do. Learn the difference with simple examples, roles, permissions, 401 vs 403 and common mistakes.
In this article
- The Short Answer
- A Simple Analogy
- What Is Authentication?
- What Is Authorization?
- Side-by-Side Comparison
- 401 vs 403: A Common Confusion
- How Authorization Is Usually Built
- A Real Example in Code
- Where You See Both Every Day
- Common Mistakes to Avoid
- Authentication vs Authorization FAQ
- Key Takeaway
- Mini Cheat Sheet
Authentication and authorization sound almost the same, and people mix them up all the time. Both are about security, both happen when you use an app, and both are often shortened to "auth". But they answer two completely different questions.
The Short Answer
- Authentication answers: "Who are you?"
- Authorization answers: "What are you allowed to do?"
Authentication always comes first. An app can't decide what you're allowed to do until it knows who you are.
A Simple Analogy
Think about checking into a hotel:
- At the front desk, you show your ID. The receptionist confirms you are the person who booked. That's authentication.
- You receive a key card. It opens your room, the gym and the pool, but not other guests' rooms or the staff office. That's authorization.
Being a verified guest doesn't mean you can go everywhere.
What Is Authentication?
Authentication is the process of verifying identity. Common methods include:
- Email and password
- One-time codes (OTP) by SMS or email
- Authenticator apps and two-factor authentication
- "Sign in with Google" and other social logins
- Fingerprint, face unlock and passkeys
For the full picture, read How Authentication Works.
What Is Authorization?
Authorization is the process of checking permissions: whether a verified user may view a page, edit a record or perform an action.
Examples:
- A customer can view their own orders, but not other customers' orders.
- An editor can publish blog posts, but cannot change billing settings.
- An admin can manage users and settings.
- A free plan user can create 3 projects; a pro user can create unlimited projects.
Side-by-Side Comparison
- Question asked: authentication asks "Who are you?"; authorization asks "Can you do this?"
- When it happens: authentication happens first, usually at login; authorization happens on every protected action.
- What it checks: authentication checks credentials like passwords, codes or passkeys; authorization checks roles, permissions or ownership.
- Who controls it: users can update their own credentials; permissions are set by the app or an admin.
- Error when it fails: authentication failure usually returns 401 Unauthorized; authorization failure returns 403 Forbidden.
401 vs 403: A Common Confusion
These two HTTP status codes map directly to the difference:
- 401 Unauthorized really means "not authenticated". The app doesn't know who you are. Log in and try again.
- 403 Forbidden means "not authorized". The app knows who you are, but you don't have permission.
The name "Unauthorized" for 401 is a historical naming mistake that still confuses developers today.
How Authorization Is Usually Built
Role-Based Access Control (RBAC)
Users are given roles (admin, editor, viewer), and each role has a set of permissions. It is simple to understand and covers most apps.
Permission-based access
Users or roles get fine-grained permissions like posts.publish or users.delete.
Ownership rules
A user can edit a resource only if they own it. For example, you can edit your comment but not someone else's.
Attribute-Based Access Control (ABAC)
Rules based on attributes, such as "managers can approve expenses under ₹50,000 from their own department". Powerful, but more complex.
A Real Example in Code
In a Laravel app, the two steps often look like this:
// Authentication: only logged-in users can reach this route
Route::middleware('auth')->group(function () {
Route::put('/posts/{post}', [PostController::class, 'update']);
});
// Authorization: inside the controller, only the owner may update
public function update(Request $request, Post $post)
{
$this->authorize('update', $post); // returns 403 if not allowed
$post->update($request->validated());
}
The middleware makes sure you are logged in. The authorize call makes sure you are allowed to edit this specific post.
Where You See Both Every Day
- Google Drive: you log in (authentication); a shared file is "view only" or "can edit" (authorization).
- Banking apps: you log in with a PIN or fingerprint; you can see your accounts but not someone else's.
- Company tools: you sign in with SSO; HR can see salaries, engineers can't.
- APIs: an API key identifies your app; the key's scopes decide what it can access.
Common Mistakes to Avoid
- Checking authentication but forgetting authorization. A logged-in user changes the ID in a URL from
/invoices/101to/invoices/102and sees another customer's invoice. This bug, called IDOR, is one of the most common security flaws. - Hiding buttons instead of blocking actions. Hiding the "Delete" button in the interface is not security. Always check permissions on the server.
- Giving everyone admin rights "temporarily".
- Hard-coding permissions throughout the code instead of keeping rules in one place.
- Returning 404 vs 403 inconsistently, which can leak whether a private resource exists.
Authentication vs Authorization FAQ
Can you have authorization without authentication?
Rarely. Some public resources have rules for anonymous visitors, like "guests can read but not comment". In practice, most authorization depends on knowing who the user is.
Is OAuth authentication or authorization?
OAuth 2.0 is designed for authorization: giving an app permission to access your data. OpenID Connect, built on top of OAuth, adds authentication. "Sign in with Google" uses both.
Is an API key authentication or authorization?
Both. The key identifies the caller (authentication), and the permissions or scopes attached to it decide what it can do (authorization).
Key Takeaway
Authentication proves who you are. Authorization decides what you can do. Authentication happens once at login; authorization is checked every time you try to access something protected, and it must always be enforced on the server.
Mini Cheat Sheet
- Authentication: identity, login, credentials, 401
- Authorization: permissions, roles, ownership, 403
- RBAC: permissions grouped by roles
- IDOR: missing ownership check on IDs
Related: Learn how API endpoints return 401 and 403 responses, and check that your login pages use HTTPS with our free SSL checker.
Join the conversation
What do you think?
Write a comment
No comments yet. Be the first to share a thought.