Mert Özen Further With Every Line
Backend .NET Core Web API — #19

Authentication and Authorization: The Difference Between Identity Verification and Permission

Mert Özen Aug 15, 2026 11 min 22 views
Authentication and Authorization: The Difference Between Identity Verification and Permission

We separate two concepts most developers confuse: authentication (who are you?) and authorization (what are you allowed to do?). The difference, the correct order, and how these are positioned in .NET.

We begin the security and identity block by separating two words most developers confuse without realizing it: authentication and authorization. Both start with "auth," both are about security, but they answer two completely different questions. Moving to JWT, roles, and policies without settling this distinction clearly is like adding floors to a building without a solid foundation. So today we go slowly and carefully.

Two Different Questions

We can summarize everything in a single sentence. Authentication asks the question "who are you?" Authorization asks "are you allowed to do this?" The first verifies your identity, the second determines what that identity can access. And the order is always this: first we understand who you are, then we look at what you're allowed to do.

The distinction is a clean and important one. Authentication means identity verification. Authorization means granting permission. Verifying your identity is one thing, granting you permission is another. To avoid confusing the two, keep this pairing in mind.

A Hotel Analogy

The clearest analogy is a hotel. When you enter the hotel, you first go to the reception and show your ID. The reception recognizes you as "yes, you're really the person who made the reservation." This is authentication: you proved who you are, the system recognized you. In return, you're given a room card.

But that room card doesn't open every door. It opens your own room's door, maybe the gym and the pool. But it doesn't open someone else's room, the staff section, or the vault. Which doors your card opens is your permissions. This is authorization: your identity is known, but you can't enter everywhere, only the places you have permission for. Having verified your identity doesn't mean you can access everything.

Why Authentication First?

The order isn't a coincidence, it's a necessity. To be able to say what a person is allowed to do, you first need to know who that person is. You can't grant permission to someone whose identity is unknown; saying "I don't know who you are but you can enter here" is meaningless. So authorization is always built on top of authentication. First identity, then permission.

In the thirteenth article we talked about why the order of middleware matters; and this concept comes right up there. In .NET, app.UseAuthentication() always comes before app.UseAuthorization(). If you reverse the order, the permission check tries to run while there's no identity yet, and the logic collapses. The "you can't ask about permission without verifying who" example in the second article was exactly this.

How Do These Two Look in .NET?

Let's look at how the two concepts reflect in code. We say that an action method requires permission, in its simplest form, with an attribute:

[HttpGet]
[Authorize]
public IActionResult GetSecret()
{
    return Ok("Only authenticated users can see this content.");
}

The [Authorize] attribute here says: "To reach this endpoint, your identity must first be verified." If a request with an unverified identity arrives, .NET automatically returns 401 Unauthorized. This is the standard way of saying "I don't know who you are, verify your identity first." It's turned away at the door, without ever entering.

So what if someone with a verified identity but insufficient permission arrives? Then they get a different response: 403 Forbidden. The distinction between these two status codes summarizes exactly today's topic. 401 means "I don't know who you are"; it's an identity problem. 403 means "I know who you are but you don't have permission here"; it's a permission problem. We touched on these two while discussing status codes in the fifth article; now why they're different is much clearer.

Narrowing the Permission

Using [Authorize] alone means "any authenticated user can enter." But often you want finer tuning: like "only administrators can enter." This is where the real power of authorization comes in. You can narrow access by adding a condition to the attribute:

[HttpDelete("{id}")]
[Authorize(Roles = "Admin")]
public IActionResult Delete(int id)
{
    return Ok($"Record number {id} was deleted.");
}

This endpoint is now open only to users who are authenticated and have the "Admin" role. An ordinary user, even with a correct identity, can't access here and gets a 403. We'll get into the details of roles and the more flexible policies in later articles; for now, what you need to see is that authorization can make much finer tunings than the "can enter / can't enter" binary.

A Small Experiment

In this article I want to settle the concept more than write code, so let the experiment be a thoughtful one too. Think of an application you use yourself, for example a social media platform or a banking app. The moment you log in, authentication happens: the system recognizes you. Then, within the application, you can do some things and can't do others; you can't edit someone else's profile, you can't see the money of an account that isn't yours. These restrictions are authorization. In the applications you use daily, try to separate these two layers in your mind; this habit will guide you when structuring the two in code too.

In the next article we'll bring authentication to life in the real sense: we'll talk about identity verification with JWT (JSON Web Token). After verifying a user's identity once, we'll see step by step how it's carried in subsequent requests and how the API recognizes this identity securely. The "first who, then permission" logic you settled today will be at the very heart of that mechanism.