Identity and access Authentication vs authorization 4 min read
Authentication vs authorization
At the airport you show your passport at security, then your boarding pass at the gate. Why two checks, if you’re the same person both times?
-
Who you are, then what you may do
The passport proves who you are. That’s authentication: in an app, a password, a passkey or a fingerprint.
The boarding pass says what you’re allowed to do: board this one flight. That’s authorization: open this file, delete that project, see this invoice. It’s checked again for every action, not once at the door.
Authentication happens once at the door. Authorization happens at every action after it. In short Authentication proves who you are. Authorization decides what you may do.
-
Even the status codes get it muddled
An API answering
401 Unauthorizedactually means “I don’t know who you are”: authentication is missing.403 Forbiddenmeans “I know who you are, and you can’t do this”: that’s authorization.In short 401 is about who you are. 403 is about what you may do.
-
Signed in isn’t the same as allowed
Priya is signed in. She changes the address from
/invoices/1042to/invoices/1043and sees another customer’s invoice.Authentication worked; she really is Priya. What’s missing is the second check: does invoice 1043 belong to her? This gap is one of the most common bugs on the web.
Priya, signed in, asks for her own invoice 1042 and gets it. She then asks for invoice 1043. The app confirms she is signed in but never checks who owns the invoice, and returns someone else’s.
The app asked “who is this?” but never “is this hers?” In short Check that this user may touch this record, on every request.
What authentication doesn’t give you
Knowing who someone is says nothing about what they’re allowed to do. A strong sign-in with MFA and passkeys still leaves every record open if the app never checks ownership.
And authorization is only as good as its weakest endpoint. One forgotten API route that skips the check is enough.
Keep this
Authentication proves who you are. Authorization decides what you may do, on every request.
Being signed in is not permission. Check that this user may touch this record, every time.- Authentication
- Who are you? A password, a passkey, a fingerprint.
- Authorization
- What may you do? Read, edit, delete, this record or that one.
- Order
- Authentication comes first; authorization runs on every action after.
Questions worth carrying
Why is 401 called “Unauthorized” if it means not authenticated?
A naming accident in the HTTP spec. 401 means “who are you?”; 403 means “I know, and no”.
Where should authorization checks live?
On the server, for every request that touches data. Hiding a button in the interface isn’t a check.