Security Playbook
02 · FundamentalsOWASP A01:20256 min read

Authentication vs authorization: who you are vs what you can do

Two words that sound alike and fail in very different ways. Authentication proves identity once; authorization has to be checked on every single request, for every single resource.

In one sentence

Authentication answers *who are you?* Authorization answers *are you allowed to do this, to this thing, right now?* Most breaches of web apps are the second one missing.

Two different questions

When Ana logs in with her password, the server authenticates her: it now knows that requests carrying her session cookie come from Ana. That's all it knows.

When Ana then asks for invoice 43, a second question must be asked: does invoice 43 belong to Ana, or does Ana have a role that lets her see other people's invoices? That's authorization, and it depends on the user, the action and the specific resource.

Authentication vs authorization
Ana's browserAPIInvoices DB01 POST /login (email + password)Authentication: Authentication: who are you?02 Session cookie: you are Ana (user 7)Authentication: Ana is logged in03 GET /invoices/43 with Ana's cookieAuthorization: Invoice 43 belongs to Bob
Being logged in (authentication) only says who you are. Every request still needs a check of what you are allowed to do (authorization). Missing that check is the #1 web risk.
Without the authorization check, any logged-in user can read any invoice just by asking for it.

Ways to decide what someone can do

ModelRule looks likeGood for
Ownershipuser.id === invoice.ownerIdPersonal data: orders, messages, files
RBAC (roles)user.role in ['admin', 'support']Back offices with a few clear job types
ABAC (attributes)same team AND document not archived AND office hoursComplex enterprise rules
ReBAC (relationships)user is editor of folder that contains the docSharing models like Google Drive
// Authorization lives next to the data access, on the server
const invoice = await db.invoice.findUnique({ where: { id } });
if (!invoice || invoice.ownerId !== session.userId) {
  return new Response("Not found", { status: 404 });
}
return Response.json(invoice);

Where it goes wrong

  • Hiding the button instead of checking on the server. The UI isn't a security control; anyone can call the API directly.
  • Checking once at login. Roles change, users get removed from teams: decide on each request.
  • Trusting IDs or roles sent by the client. role=admin in a request body or an unsigned cookie is a wish, not a fact.
  • One check per endpoint, not per resource. "Is logged in" passes; "owns this record" was never asked.

Key takeaways

  • 01Authentication = identity. Authorization = permission for this action on this resource.
  • 02Authorization must be checked on the server, on every request.
  • 03Never trust roles, IDs or prices coming from the client.
  • 04Deny by default and return 404/403 when the user doesn't own the resource.

Check your understanding

1 of 3

Authorization answers which question?

Related concepts