Skip to main content
Technical Enough

Auth, who you are vs. what you can do

Chapter 6 of 7 in The Technology Stack · 19 min

The night before you show the consultancy portal to the partner whose clients it will hold, you sign in as one consultant and click through your own client list one last time. The address bar reads portal.example.com/clients/1041, and the numbers look like they count up one at a time, so out of idle curiosity you change 1041 to 1042 and press return. The page shows a different consultant's client: meeting notes, a billing dispute, a draft apology letter, none of it yours. The login screen worked exactly as it was built to. It checked who you were once, when you signed in, and after that the portal checked nothing, so you have just read a stranger's file using nothing more technical than an address bar.

Nothing in that scene was hacked. Auth, the engineers' short word for an app's accounts and sign-in, covers two checks. The tool that built the portal was asked only for a login screen, so it built only the first check.

Auth is two checks, not one

Authentication checks who you are. It works like a hotel's front desk: the sign-in flow turns an anonymous visitor into a known user and hands them a keycard. Engineers shorten it to authN.

Authorization checks what you may do. It works like the door reader on every hotel room: a permission rule runs when a known user tries to read a record. Engineers shorten it to authZ. It belongs on every request the backend handles, because every request asks to read or change something, the way every guest taps a keycard on some door.

What you did in the address bar is called broken access control: a signed-in user reaching records that no permission rule checked. It is first on the OWASP Top 10, the industry's ranked list of the most serious security risks in web applications, and in the portal it comes down to one missing permission check on one door.

An app is only safe when both checks run as separate jobs: authentication confirms who someone is, and authorization checks, on every request, what that person may do.

Authentication versus authorization, two separate checksTwo panels. Left, authentication, the front desk: it asks who are you, turns an anonymous visitor into a known user, and runs once at sign-in. Right, authorization, the door reader, drawn in spruce as the half beginners drop: it asks what may you do, decides whether a known user can read a record or open an admin page, and runs on every request. Caption: a login proves who you are once; the permission check is separate work, on every request.AUTHENTICATIONAUTHORIZATIONWho are you?the front desk, the sign-in flowONCE, AT SIGN-INWhat may you do?the door reader, the permission ruleEVERY REQUESTA login proves who you are once; the permission check runs on every request.

The drawing shows the difference in timing: the front desk checks who you are once, at sign-in, and the door reader checks what you may do on every request.

What happens when you sign in

Here is the portal's sign-in in three moments. The addresses and lines below follow the format real sites use; only the portal and its domain, the site name in its address (portal.example.com), are made up.

The hand-off. Click "Sign in with Google" and the address bar changes to a Google address. Here it is, trimmed to the parts that matter:

https://accounts.google.com/o/oauth2/v2/auth
    ?client_id=8123...apps.googleusercontent.com
    &redirect_uri=https://portal.example.com/auth/callback
    &scope=openid email

The portal never sees your password. It sends your browser to Google with three details: client_id (which app is asking), redirect_uri (where Google sends you back), and scope (what the portal may learn about you: who you are and your email, nothing more). Engineers call this kind of borrowed sign-in OAuth, and every consent screen you have clicked ("Allow this app to view your email address") is a scope written out in plain words for people.

The keycard. Back at the portal, the response includes one line that matters:

Set-Cookie: session=eyJhbGciOi...trimmed...; HttpOnly; Secure

That line tells the browser to keep a cookie, a small labeled value that the browser attaches to every request it sends to the portal from now on. The cookie holds the session, your signed-in state: it is the keycard from the front desk. Some apps check twice before the session starts: the six-digit code they text you is a second factor, extra proof that you are who you say you are.

The doors. Repeat the opening's address-bar edit, still signed in:

GET /clients/1041  ->  200 OK    your client's notes
GET /clients/1042  ->  200 OK    another consultant's client, rendered anyway

A GET is the browser asking to read something, and 200 OK is the status code that says the request worked. The same valid cookie went with both requests, so authentication passed twice, but no part of the portal checked whether this user may read this record. With door checks in place, the second line ends in 403 Forbidden, a status code that means the server has confirmed who you are from the cookie and still refuses. That is the URL-swap test: ask for an ID that is not yours and read the reply.

The drawing shows the same two requests with the door check in place: the same cookie went with both, the first got 200 OK, and the second got 403 Forbidden.

Never build login yourself

Login looks like a small feature for a beginner, but it depends on decades of solved problems: storing passwords so that a stolen database does not expose them, password-reset emails that cannot be hijacked, and sessions that expire on time. If you build it yourself, you will get these wrong one at a time. If you rent the sign-in flow from a service such as Clerk, Auth0, or Supabase Auth, you never store a password, and your job comes down to the three-line spec later in this chapter.

The sign-in methods to choose from

When the service asks which sign-in methods to turn on, the list is short.

  • Email links. The user clicks a link sent to their email and is signed in; no password exists at all. Apps call these magic links.
  • Sign in with Google or Apple. This is the borrowed sign-in you just traced: one button, and Google or Apple confirms who the user is through an account the user already trusts.
  • Passwords. They are still everywhere and still the weakest choice: a password reused on several sites is exposed when any one of those sites is breached.
  • Passkeys. A passkey is a secret your device creates for one site, and you approve each sign-in with whatever you already use to open your phone. A phishing page, a fake sign-in page built to steal what you type, has nothing to capture, because you never type a passkey and it works only on the real site, and passkeys are now the default on Apple, Google, and Microsoft accounts, so you have probably already used one.

An email link plus one "Sign in with Google" or "Sign in with Apple" button works for nearly everyone, and adding a method later is a setting you change, not a project.

The objection: your agent can set up login from one sentence

The obvious objection is that one sentence to your coding agent already produces a working login: it sets up a sign-in service, connects the screens, and handles the cookie. That is true, and it is why you rent sign-in instead of building it. But one sentence cannot include decisions you have not made: who may sign up, which roles (kinds of user, such as consultant and partner) exist, and where the harm line sits, meaning which actions would do real harm in the wrong hands. Whatever you leave out, the tool fills in with defaults, and no default says which consultant may open which client, so the tool sets up the sign-in and builds no door checks. Cost does not change the answer: auth services are typically free for the first few thousand users and then charge per active user, and the expensive mistakes come from the rules you never wrote.

Many first builds need no auth at all

Accounts are work that never ends: you maintain the sign-in flow, help users who are locked out, and hold personal data that a breach could expose. A tool only you run, or a public site showing everyone the same content, needs none; we shipped this site with no accounts.

The test for your build: finish this sentence for each feature you planned to put behind a sign-in: "If any stranger on the internet could do this, the specific harm would be..." When you cannot think of a specific harm, skip auth; adding a service later is days of work, not a rewrite. When the harm is obvious (private records, money moving, posts under someone's name), you need both checks from day one.

The three-line auth spec

When your build actually needs accounts, give your coding agent three lines before it sets up login: who signs up, how they sign in, and what each kind of user may do.

  1. Who signs up. Anyone with an email address, only people you invite, or only addresses at one company's domain.
  2. How they sign in. Pick from the list of methods above, such as an email link plus Google.
  3. What each kind of user may do. Name the roles and say what each one may and may not do.

For the consultancy portal, the spec reads: anyone with a company email address can sign up; they sign in with Google; consultants see only their own clients, while partners see every client plus invoicing. That third line is the authorization half, the rule that was missing when the portal showed you client 1042. Once that rule is written down and the check for it is built, the portal answers that request with 403 Forbidden. Hand the three lines to your agent and setting up the sign-in and the checks becomes its job; the spec also goes straight into your Build Plan in Finish your Build Plan and launch.

Try it now

The drill takes about fifteen minutes, and you spend nothing. You arrive with the idea file from Decode the technical questions that stop you and leave with your AUTH SPEC added to it.

No setup: Audit the sign-in of two AI apps you already use, say a chat assistant and a meeting notetaker. On each sign-in screen, list the methods: password, email link, Google or Apple, passkey. Click a borrowed sign-in: the hand-off address appears briefly in the address bar, the consent screen shows the scope, and at least one app asks for a second-factor code. Sign out and note what you can no longer reach; you are working out each app's auth spec from the outside.

With your tools: Write the three-line AUTH SPEC for your idea, paste it into Claude Code, and ask which auth service it would use and what it would check on each request to enforce your third line. Same move in Codex or Cursor: give the sidebar chat your spec and ask for the service pick and the per-request check. If your tools are not set up yet, The Setup Clinic gets you there.

Either way, add to the idea file. Save the three lines under the heading AUTH SPEC; if your honest first line is "no accounts yet", write that plus the harm sentence instead. You use either version in the Build Plan.

Chapter Summary

  • Auth bundles two checks: authentication proves who a user is, authorization checks what that user may do, and a login screen only delivers the first.
  • The permission check runs on every request that reads or changes data, not once at sign-in, because each of those requests asks for a specific record and needs its own yes or no.
  • The classic failure is broken access control, the top risk on the OWASP Top 10: a signed-in user changes an ID in a URL and reads a stranger's record because no permission rule checked the request.
  • A sign-in has three visible moments: a hand-off URL that says which app is asking and what it may learn, a session cookie the browser attaches to every later request, and a door check (or its absence) on each record you ask for.
  • Never build login yourself; rent it from a service such as Clerk, Auth0, or Supabase Auth, and you never store a password.
  • The sign-in methods range from email links through Google and Apple buttons to passkeys, now the default on Apple, Google, and Microsoft accounts; passwords remain the weakest choice.
  • Your agent can set up the sign-in from one sentence, but who signs up, which roles exist, and where the harm line sits are decisions only you can make.
  • Many first builds need no accounts at all; when you cannot name the specific harm a stranger could do, skip auth for now.
  • Your AUTH SPEC is three lines, who signs up, how they sign in, and what each role may do, saved in your idea file for the Build Plan.
  • Everything you have built so far can fail quietly, sign-in included, and Monitoring, how you know it broke (and what it costs) is how you find out before your users do.

Sources

  • OWASP Top 10, where broken access control holds the top position in the 2025 revision (last verified July 2026).
  • Google Identity documentation on OAuth 2.0 for web sign-in (last verified July 2026).
  • FIDO Alliance documentation on passkeys and platform support (last verified July 2026).