Authorization models

RBAC vs ABAC, enforcing at the resource layer, IDOR — the most common real-world authz bug. "Who can call this and how do you know" applies to every endpoint.

About 27 min read3-question knowledge check

The mental model

Authentication checked your ID at the door — it knows *who you are*. Authorization is the bouncer inside deciding *which rooms you may enter*. They are different questions with different failure codes: failing authentication is 401 ("I don't know who you are"), failing authorization is 403 ("I know who you are, and you may not do this"). Confusing the two is a classic interview tell and a real bug — a system that returns 401 for a permission failure misleads clients and breaks their retry and re-login logic, while one that returns 403 where 404 is appropriate leaks that the resource exists to someone who should never learn that.

Two models cover almost everything:

  • RBAC (Role-Based Access Control) is a keycard system. Your card is programmed with a role — "nurse", "editor", "billing-admin" — and each door is programmed with which roles it accepts. Simple, auditable, and the right default. Its weakness: roles are coarse. "Editor can edit articles" cannot express "editor can edit their own articles but not others'".
  • **ABAC (Attribute-Based Access Control)** is a rule engine over attributes of the *user*, the *resource*, and the *context*: "allow if user.dept == resource.dept AND time is business hours AND user.clearance >= resource.classification". Infinitely expressive; harder to audit and reason about.

The single most important idea, the one that causes more real breaches than any exotic attack: **authorization must be enforced at the resource, on the server, every time — and it must be about the specific object being accessed, not just the action.** Knowing a user is a logged-in "customer" (a role check) is not the same as knowing they own *order #4471* (an object check). Skipping the object check is **IDOR** (Insecure Direct Object Reference), and it is the number-one authorization bug in the wild: GET /api/orders/4471 returning someone else's order because the code checked "is this a logged-in user?" and never "is 4471 theirs?"

Why this exists: without authorization, authentication is a guest list with no rooms — everyone who gets in the door can go anywhere. And without object-level authorization, you have room-level locks but every key opens every locker.

The full lesson continues with 15 more sections
  • Deep dive
  • Internal architecture
  • Real-world use cases
  • Best practices
  • Common mistakes
  • Performance
  • Security
  • Production troubleshooting
  • Advantages & disadvantages
  • Alternatives
  • Interview expectations
  • Interview questions
  • Facts to remember
  • Cheat sheet
  • Quick revision