Appearance
Identity Basics
21. What is authentication, and how is it different from authorization?
The short answer
Authentication answers "who are you?": the user proves their identity, with a password, a passkey, a one-time code or a certificate. Authorization answers "what are you allowed to do?": the system checks whether this identity may perform this action on this resource. Authentication comes first, and authorization happens on every request after it. A failed authentication returns 401 Unauthorized, which despite its name means "not authenticated". A failed authorization returns 403 Forbidden.
A hotel makes the difference concrete. At the front desk you show your passport. That is authentication. You get a key card. The key card opens your room and the gym, but not other guests' rooms or the staff office. That is authorization. A thief with a stolen key card passes authorization without ever authenticating, which is why stolen tokens are so dangerous.
ts
app.get('/api/orders/:id',
requireUser, // (1)
async (req, res) => {
const order = await orders.findById(req.params.id)
if (!order) throw new HttpError(404, 'Order not found')
if (order.customerId !== req.user.id && !req.user.roles.includes('support')) {
throw new HttpError(403, 'Not your order') // (2)
}
res.json(order)
})- Authentication:
requireUserchecks the session or token and setsreq.user, or responds401. - Authorization: this user is known, but may only see their own orders, unless they work in support.
| Authentication | Authorization | |
|---|---|---|
| Question | Who are you? | What may you do? |
| When | At login, or each request with a token | Every request, every resource |
| Failure code | 401 Unauthorized | 403 Forbidden |
| Tools | Passwords, MFA, passkeys, OIDC, SAML | Roles, permissions, policies, OAuth scopes |
The bug interviewers look for: checking authentication and forgetting authorization. "The user is logged in, so show order 1043" lets any customer read any order by changing the number. This is broken object-level authorization, the most common API vulnerability (the OWASP question).
22. What is digital identity?
The short answer
A digital identity is the set of data a system uses to represent a person, device or program. It has a unique identifier, such as a user ID or email; attributes, such as name, department and roles; and one or more credentials that prove control of it, such as a password, a passkey or a certificate. One real person usually has many digital identities, one per organisation or service, and some systems link them together.
| Part | Example for an employee |
|---|---|
| Identifier | asha.rao@shop.example, or an immutable ID such as 8f3c… |
| Attributes | Name, department Finance, manager, groups |
| Credentials | Password and a passkey on her laptop |
| Lifecycle | Created when she joins, changed when she moves team, disabled when she leaves |
Use an immutable ID, not the email. Emails change when people marry, change names or the company rebrands. If your database links orders to asha.rao@… and she becomes asha.mehta@…, her history breaks, or worse, a new employee who later gets the old address inherits it. Identity providers give every account an ID that never changes, such as OIDC's sub claim. Link to that.
Non-human identities count too. Services, CI pipelines and devices also have identities, with credentials such as client secrets, certificates or cloud roles. In many companies they outnumber human users.
23. What is identity management?
The short answer
Identity management is the work of handling identities through their whole life. It covers creating accounts when someone joins, often automatically from the HR system; changing their attributes and access when they move roles; authenticating them; reviewing who has access to what; and removing access promptly when they leave. The joiner, mover, leaver process is the core of it. Most breaches through old accounts happen because the leaver step was missed.
The joiner, mover, leaver process:
- Joiner. HR records a new hire. The identity system creates an account, puts them in the right groups for their department, and sends account details to the apps they need (SCIM provisioning).
- Mover. They move from Sales to Finance. Finance access is added and Sales access is removed. Skipping the removal leads to "privilege creep", where long-serving staff hold access from every job they ever had.
- Leaver. On their last day, the account is disabled everywhere at once, sessions are revoked, and their devices are wiped.
Why central identity makes this possible. If every app has its own user list, a leaver must be removed from fifty places by hand, and someone always forgets one. With one identity provider and single sign-on, disabling one account closes every door.
24. What is Identity and Access Management (IAM)?
The short answer
IAM is the combined set of policies, processes and tools that make sure the right identities get the right access to the right resources, for the right reasons, and that you can prove it. It joins identity management, which covers accounts and their lifecycle, with access management, which covers authentication, single sign-on and authorization. In the cloud, "IAM" also names the specific service, such as AWS IAM, that controls which users and roles may call which cloud APIs.
| Area | Covers | Example tools |
|---|---|---|
| Identity lifecycle | Joiner, mover, leaver; provisioning | Entra ID, Okta, HR-driven SCIM |
| Authentication | Login, MFA, passkeys, SSO | An identity provider |
| Authorization | Roles, permissions, policies | Your app's checks, cloud IAM policies |
| Privileged access | Admin accounts, just-in-time elevation | Privileged access management tools |
| Governance | Access reviews, audit, compliance reports | Identity governance tools |
Cloud IAM in one example. An AWS IAM policy that lets the orders service read one bucket:
json
{
"Effect": "Allow",
"Action": ["s3:GetObject"],
"Resource": "arn:aws:s3:::shop-receipts/*"
}The service runs with a role that has only this policy attached. Least privilege, written down as data (the least privilege question).
25. What is an Identity Provider (IdP)?
The short answer
An identity provider is the service that holds user accounts and does the logging in, then tells other applications who the user is. Examples are Microsoft Entra ID, Okta, Google, Auth0 and Keycloak. Applications do not check passwords themselves. They redirect the user to the IdP, the IdP authenticates them with password, MFA or passkey, and sends back a signed statement, an OIDC ID token or a SAML assertion, saying "this is Asha, she logged in with MFA at 10:02". The app trusts that statement because it trusts the IdP's signature.
Why not let every app check passwords itself?
- One login for the user, across every app. This is single sign-on.
- One place to secure. MFA, passkeys, breached-password checks and suspicious-login detection are built once.
- One place to disable a leaver (question 23).
- Apps never see passwords, so a breached app leaks no credentials.
The cost is dependence. If the IdP is down, nobody can log in to anything. Choose a highly available IdP and plan for its outage.
26. What is a Service Provider (SP)?
The short answer
A service provider is the application the user actually wants to use, such as Salesforce, Slack or your company's expense app, which relies on an identity provider to log users in. The term comes from SAML. In OAuth and OpenID Connect the same role is called the relying party or the client. The SP sends the user to the IdP, receives a signed assertion back, checks the signature and the details, then creates its own session for the user.
| Protocol | Name for the app | Name for the login service |
|---|---|---|
| SAML | Service provider (SP) | Identity provider (IdP) |
| OpenID Connect | Relying party (RP), or client | OpenID provider (OP) |
| OAuth 2.0 | Client | Authorization server |
What the SP must still do itself: check the assertion properly, map the identity to its own user record, decide what the user may do inside the app, and manage its own session and logout. The IdP proves who the user is. It does not decide what they may do in your app.
27. What are identity federation and federated authentication?
The short answer
Federation is a trust agreement between separate organisations or systems, so that an identity from one is accepted by another without a new account and password. Federated authentication is logging in to an app using that trust: you sign in to a partner's portal with your own company's account, or to a website with "Sign in with Google". Your home IdP authenticates you and sends a signed assertion. The other side trusts it because the two exchanged keys, and agreed on attributes, in advance, using SAML or OpenID Connect.
Why federation is valuable:
| Without federation | With federation |
|---|---|
| A separate password for each partner site | Her normal work login |
| The partner must remove her when she leaves | Acme disables her account, and access ends everywhere |
| Partner stores her password | Partner stores no password at all |
Federation versus SSO. Single sign-on is logging in once for many apps. Federation is the trust that makes it work across organisational boundaries. SSO inside one company may not need federation between companies, but it uses the same protocols (the SSO question).