Skip to content

Interview PrepAuthentication · Basics

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)
  })
  1. Authentication: requireUser checks the session or token and sets req.user, or responds 401.
  2. Authorization: this user is known, but may only see their own orders, unless they work in support.
AuthenticationAuthorization
QuestionWho are you?What may you do?
WhenAt login, or each request with a tokenEvery request, every resource
Failure code401 Unauthorized403 Forbidden
ToolsPasswords, MFA, passkeys, OIDC, SAMLRoles, 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.

PartExample for an employee
Identifierasha.rao@shop.example, or an immutable ID such as 8f3c…
AttributesName, department Finance, manager, groups
CredentialsPassword and a passkey on her laptop
LifecycleCreated 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:

  1. 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).
  2. 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.
  3. 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.

AreaCoversExample tools
Identity lifecycleJoiner, mover, leaver; provisioningEntra ID, Okta, HR-driven SCIM
AuthenticationLogin, MFA, passkeys, SSOAn identity provider
AuthorizationRoles, permissions, policiesYour app's checks, cloud IAM policies
Privileged accessAdmin accounts, just-in-time elevationPrivileged access management tools
GovernanceAccess reviews, audit, compliance reportsIdentity 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?

  1. One login for the user, across every app. This is single sign-on.
  2. One place to secure. MFA, passkeys, breached-password checks and suspicious-login detection are built once.
  3. One place to disable a leaver (question 23).
  4. 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.

ProtocolName for the appName for the login service
SAMLService provider (SP)Identity provider (IdP)
OpenID ConnectRelying party (RP), or clientOpenID provider (OP)
OAuth 2.0ClientAuthorization 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.

Ashaworks at Acmesupplier portal④ lets Asha inAcme's IdP② password + MFAopens the portal① sent to Acme to log intrust set upin advance③ signedassertion
Your company vouches for you. ① The partner's portal sends Asha to her own company's IdP. ② She logs in the usual way. ③ Her IdP sends a signed assertion. ④ The portal accepts it, because the two organisations exchanged keys beforehand. Asha never gets a separate password for the portal.

Why federation is valuable:

Without federationWith federation
A separate password for each partner siteHer normal work login
The partner must remove her when she leavesAcme disables her account, and access ends everywhere
Partner stores her passwordPartner 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).

Combine chapters into one PDF

Pick the chapters you want. They print in the order you pick them.

Interview Prep
Authentication & Identity
Cookies & sessions
Authentication
Tokens
OAuth & OIDC
Enterprise SSO
Directories
Authorization
Other topics
Nothing picked yet