IAM interview questions · Fundamentals
What is the difference between authentication and authorization?
In plain wordsAuthentication is the passport check: who are you? Authorization is the boarding pass: which plane can you board?
How it works
Authentication (AuthN) answers one question: is this really the person, or system, it claims to be? It uses factors: a password, a passkey, a certificate, a biometric unlocking a key. The output is an authenticated identity, usually a session or a token with a subject identifier.
Authorization (AuthZ) starts from that identity and decides, request by request, whether an action on a resource is allowed. The decision can use roles (RBAC), attributes (ABAC), relationships (ReBAC, “is this user the owner of this document?”) or scopes in a token. It is usually spread across layers: the IdP limits scopes, the gateway checks coarse permissions, the application checks the individual object.
HTTP makes the difference visible: 401 Unauthorized really means “not authenticated”, 403 Forbidden means “authenticated, but not allowed”.
See it in action
One login, from click to “access denied”
Authentication, SSO, sessions and authorization in a single story: Marco opens the invoices app.
- Marcothe user, in a browser
- Appthe invoices website
- IdPthe login service
- APIwhere invoices live
Step 1 of 8 · Marco → App
Marco opens the app
In plain words The app does not know who he is yet, so it does not show anything. It sends him to the login service.
In the interview, call it Redirect to the identity provider
Technical details
No session cookie: the app builds an authorization request and redirects the browser to the IdP.
Step 2 of 8 · Marco → IdP
Marco proves who he is
In plain words He types his password and confirms on his phone. Two different proofs: something he knows, something he has.
In the interview, call it Authentication, MFA
Technical details
The IdP verifies the factors and creates its own session (an SSO cookie on the IdP domain).
Step 3 of 8 · IdP → App
The IdP vouches for him
In plain words The app gets a note signed by the IdP. It trusts the signature, not the browser.
In the interview, call it ID token, access token, federation
Technical details
With OIDC the app gets an ID token (who logged in) and an access token (what it may call). It validates signature, issuer, audience and expiry.
Step 4 of 8 · App → Marco
The app remembers him
In plain words Marco will not see the login again for a while. The app keeps its own session, separate from the IdP one.
In the interview, call it Application session vs IdP session
Technical details
Two sessions with two lifetimes: logging out of the app does not log out of the IdP, and vice versa. That is why logout is hard.
Step 5 of 8 · App → API
The app asks for his invoice
In plain words The app calls the API showing the access token, like a ticket at the entrance.
In the interview, call it Bearer token, scopes
Technical details
Authorization: Bearer <token>. The API checks signature and audience, then reads scopes and claims.
Step 6 of 8 · API → App
Allowed: the invoice is his
In plain words The API checks one more thing: is invoice 381 Marco’s? Yes, so it answers.
In the interview, call it Authorization, object-level check
Technical details
A valid token is not enough: the API compares the token’s subject with the invoice owner. This is the check that most often goes missing.
Step 7 of 8 · App → API
Marco changes the number in the URL
In plain words Same login, same token, but invoice 382 belongs to someone else.
In the interview, call it Broken object level authorization (BOLA / IDOR)
Step 8 of 8 · API → App
Denied: he is authenticated, not authorized
In plain words The API knows exactly who Marco is, and that is why it says no. Knowing who you are and deciding what you can do are two different jobs.
In the interview, call it Authentication ≠ authorization
Technical details
401 means “I do not know who you are”, 403 means “I know, and the answer is no”. A good interview answer uses this exact example.
A concrete example
Marco logs into an invoices portal with a passkey: authentication succeeded. He then changes /invoices/381 to /invoices/382 in the URL. The API knows exactly who he is, but invoice 382 belongs to another customer, so it must answer 403. If it answers 200, that is a broken object level authorization bug (BOLA), the top risk in the OWASP API list.
See it in action: two different questions
Mistakes to avoid
- Saying OAuth is an authentication protocol. OAuth is authorization; authentication comes with OpenID Connect.
- Treating “has a valid token” as “is authorized”. A valid token says who you are, not that you can touch this object.
- Mixing up 401 and 403 in API design.
They may also ask you
- Where would you enforce authorization in a microservices architecture?
- What is the difference between coarse-grained and fine-grained authorization?