Authentication and authorization · core
Authentication vs authorization, RBAC and ownership
Authentication proves who the caller is; authorization decides what that caller may do with a specific resource, and both must be checked on the server for every request.
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceThe notes
What you must know
- Authentication (authn): login with a password, OTP, passkey or SSO, then a session or token on later requests. Failure -> 401.
- Authorization (authz): roles (RBAC: admin, support, user), attributes and ownership (ABAC: this order belongs to this user; this doctor is assigned to this patient). Failure -> 403 (or 404 to hide existence).
- Broken Object Level Authorization (BOLA/IDOR) is the top API risk in the OWASP API Security Top 10 (2023): changing an id in the URL must not reveal another user's data.
- Least privilege: give each user, service and API key only the permissions it needs; deny by default.
- Put rules in one policy layer (can(user, action, resource)) and test it; do not scatter if (user.role === 'admin') across handlers.
- After login: create a session or tokens, regenerate the session id, record the login, maybe notify on a new device.
The red pen
Common traps: mistake → fix
Mistake: Hiding UI elements is authorization
Fix: the API must check every request.
Mistake: Authorization is checked once at login
Fix: it is checked on every request, for the specific object.
Mistake: Roles alone are enough
Fix: most real rules also need ownership or tenant checks.
Easy to hard
Questions interviewers ask, easy to hard
- Authentication vs authorization?
- What should happen right after a user logs in?
- RBAC vs ABAC: give an example of each.
- How do you prevent IDOR across hundreds of endpoints?
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceYour first interview is free
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.