algomiBlogs
← All posts

Designing Authentication: Proving Who You Are

Algomi Research · Created 2026-09-16 · Updated 2026-10-15 · System Design

System Design Case Studies · Part 5 of 15
ATM Design: When Software Must Agree with a Physical MachineDesigning a CDN: Put Popular Content Near Its Readers
Page 1 of 1

A library card for a website, and a stolen laptop

Rohit, a class 12 student, uses PadhaiPal, a learning website, every evening. One afternoon his laptop is stolen from a bus while he's still logged in. That evening he has also forgotten his password, and his younger sister wants to "just use Sign in with Google." (Rohit, PadhaiPal, Zoya and every incident here are made up for teaching.)

Zoya designs PadhaiPal's login system. Her first principle comes from the school library. The librarian checks your card before lending a book, but the card doesn't let you open the staff cupboard. Websites need the same two separate checks:

  • Authentication asks, "Who are you?"
  • Authorization asks, "May you do this?"

A successful login must never automatically grant access to every account, file or admin action.

A session is a limited record of one successful login. The design covers registration, login, logout, account recovery and session management. The architecture is a proposal, not the implementation of a named company.

What happens to Rohit Idea it forces
"Where do we keep his password?" Salted, slow password hashes
"He logs in every evening" The login flow and sessions
"His laptop was stolen while logged in" Revocation: sessions vs signed tokens
"He forgot his password" Single-use, atomically consumed recovery tokens
"Someone phished his password" Multi-factor authentication
"His sister wants 'Sign in with Google'" OpenID Connect and safe account linking

In 30 seconds, as an architect would frame it: "One identity service owns proof of identity. Users get a stable internal ID, passwords are stored as salted Argon2id hashes, and browsers get an opaque, revocable server-side session in a Secure, HttpOnly cookie. Recovery uses short-lived, single-use tokens stored only as digests and consumed atomically with the password change. MFA raises confidence, OIDC handles external sign-in with issuer-plus-subject identity, and authorization is checked separately at every resource. I'll state the revocation delay the design actually gives."

1. "Where do we keep his password?": what to store

Requirements. Email verification, password changes, multiple devices and optional multi-factor authentication (MFA), which means proving identity with more than one kind of evidence. Sensitive changes may need a fresh check even inside a valid session.

Correctness beats convenience. If the identity store is down, a new login fails safely. Existing sessions may continue only under a deliberate validation and revocation policy.

Give each person a stable internal user ID. Rohit's email can change. Store normalised lookup values under a documented email policy, and don't assume every email provider handles dots or capital letters the same way.

Record Purpose Important constraint
User Stable ID and account status Disabling an account affects access
Credential Password hash and hashing parameters One authoritative password record
Session User, expiry, device context, revocation Session secrets stay out of logs
Recovery challenge Token digest, expiry, consumed time One successful use only
Role assignment User and allowed role Changes require authorization
External identity Provider issuer and subject ID Unique identity pair

The database never holds the original password. A password hash is a one-way check. It is not an encrypted password the application could recover.

  • Use a maintained library with a salted, deliberately expensive password-hashing function. OWASP recommends Argon2id for new systems.
  • Plain SHA-256 is unsuitable, because it's far too fast: an attacker with a leaked table can try billions of guesses a second.
  • Store the algorithm parameters with each hash, so they can be upgraded silently at the next login (OWASP password storage guidance).

2. "He logs in every evening": login and sessions

Authentication system: step 1, password login with sessionsStep 1 of 3: Password login with sessions. Components: Browser, Login and MFA checks, User and credential hash, Session management, Sessions (revocable). Verify a password against its salted hash and hand the browser a session that the server can revoke. CLIENT IDENTITY SERVICE IDENTITY STORE Browser protected session cookie over HTTPS Login and MFA checks Session management User and credential hash Sessions (revocable) sign in verify hash start session store, revocable call service data store security, network people, apps, external
Step 1: the smallest design that works.

You've reached the free preview of this post.

Subscribe to the Blogs plan (₹99/mo) — or use any Algomi Suite, Career, Investor, or Trader plan — to keep reading.

See plans

Sources

System Design Case Studies · Part 5 of 15
ATM Design: When Software Must Agree with a Physical MachineDesigning a CDN: Put Popular Content Near Its Readers