LEARN. PRACTICE. EXPLAIN.
Learning paths & interview practiceP
Backend foundations
LESSON 1 OF 8 · ABOUT 12 MINUTES + EXERCISE

What does a backend do, and who is making the request?

THE IDEA

What it is

A backend receives requests, checks input and permissions, performs business work, and returns a response. HTTP does not automatically remember that a previous request logged someone in. Authentication establishes the caller’s identity; authorization decides whether that caller may perform this action on this resource.

Why you need it

A signed-in customer should be able to read their own invoice, but being signed in should not grant access to every invoice. Separating identity from permission keeps this distinction visible in the design.

How it works

  1. The browser requests GET /invoices/42.
  2. The server identifies the caller from a validated session or credential.
  3. It loads the invoice and checks the caller’s right to read it.
  4. It returns allowed data or a documented denial response.
Pseudocode

A protected request pipeline

caller = authenticate(request)
if caller is missing: return 401
invoice = findInvoice(request.invoiceId)
if invoice is missing: return 404
if not canRead(caller, invoice): return 403
return 200 with invoice

Each function represents a server-side responsibility. Some APIs deliberately use 404 for inaccessible resources to avoid revealing existence. The browser never gets to declare its own trusted identity.

Try the local authentication lab

Download the file and run node backend-auth.mjs with Node.js 22 or newer. It tests an in-memory auth model; it is not a production login server.

Download runnable lab

Good practices and why

  • Validate both identity and resource-specific permission on the server, including download and bulk endpoints.
  • Return only needed fields and use consistent error semantics so clients can handle failures.

Common mistakes

  • Treating a hidden button as an access-control check.
  • Trusting a userId or organizationId supplied in the request body.
GUIDED IMPLEMENTATION

Try it yourself

Draw the request pipeline for viewing your own profile and editing someone else’s profile. Mark where identity is established and where permission is decided.

What a successful result looks like

Your diagram contains distinct authentication and authorization decisions, and the second operation is denied without an explicit permission.

0 / 6000 characters · Saved on this device. Do not include passwords or private data.

Check your understanding

A valid login is presented with another customer’s invoice ID. What is still required?

Answer the understanding check correctly to record exercise completion.

PUT THE IDEA UNDER PRESSURE

Related interview practice

These scenarios add constraints and follow-up questions to the concepts you just learned.

Further reading

Selected primary references · reviewed 2026-10-09. Examples are educational; use your framework’s documented integration guidance when building a deployed system.

AlifBay Prep