Session 5 Slides
Session 5 · 75 minutes · slides

Identity, Security, and Software Beyond the Browser

How the server knows who is asking, how to keep it safe, and how phones, desktops, devices, and AI fit in

  1. 5.1 Authentication versus authorization
  2. 5.2 Passwords done right
  3. 5.3 Staying logged in: cookies, sessions, tokens
  4. 5.4 HTTP Basic Authentication and API keys
  5. 5.5 OAuth: how "Sign in with Google" works
  6. 5.6 Security basics every product owner should know
  7. 5.7 Beyond the browser: mobile, desktop, embedded
  8. 5.8 Where AI fits

Arrow keys or space to move, F for full screen. Every slide has a Book button back to the full text.

Session 5 · 5.1 Authentication versus authorizationBook ↗

Two questions

Every request touching a record must check that THIS user may touch THIS record. Forgetting that has caused huge leaks.
Session 5 · 5.2 Passwords done rightBook ↗

Never store the password

Session 5 · 5.3 Staying logged in: cookies, sessions, tokens · 1/2Book ↗

How a login survives stateless HTTP

Browser Back end Session store 1 POST /login {email, password} (over HTTPS) 2. hash(password) matches stored hash? yes 3 save: a8f3…c9 = Dana, 14 days 4 200 OK Set-Cookie: session=a8f3…c9 browser stores cookie 5 GET /api/orders Cookie: session=a8f3…c9 6 who is a8f3…c9? → Dana 7 200 OK Dana's orders only
How a login survives stateless HTTP. The password is sent exactly once. Afterwards a random session ID in a cookie stands in for it, and any web server can look the ID up in the shared session store.
Session 5 · 5.3 Staying logged in: cookies, sessions, tokens · 2/2Book ↗

Consequences

Session 5 · 5.4 HTTP Basic Authentication and API keys · 1/2Book ↗

The simplest scheme, built into HTTP

HTTPS tunnel: encrypted between browser and server. Without it, the header below is readable by anyone on the network. Browser Server Authorization: Basic ZGFuYTpjb3JyZWN0LWhvcnNl = Base64("dana:correct-horse"), sent with every single request Encoding is reversible by anyone. It is not a secret; HTTPS is what makes it one.
Basic Authentication. The credentials ride along on every request in a trivially reversible encoding. The protection comes entirely from HTTPS.
Session 5 · 5.4 HTTP Basic Authentication and API keys · 2/2Book ↗

API keys are passwords for programs

The single most important habit when building with Claude Code and the Claude API.
Session 5 · 5.5 OAuth: how "Sign in with Google" works · 1/3Book ↗

The problem OAuth solves

Session 5 · 5.5 OAuth: how "Sign in with Google" works · 2/3Book ↗

The authorization-code flow

Dana's browser resource owner Bakery back end the "client" app Google login authorization server Google API resource server 1 clicks "Sign in with Google" 2 redirect to Google with client_id + scopes 3 Dana logs in at accounts.google.com (password + MFA; the bakery never sees them) 4. Consent screen: "Rosenthal's Bakery wants to see your email and name. Allow?" Dana: Allow 5 redirect back with ?code=XyZ123 (one-time code, useless alone) 6 browser delivers code=XyZ123 7 code + client_secret (server to server) 8 tokens: access (1 h), ID, refresh 9 GET /userinfo Authorization: Bearer <access token> {"email": "dana@gmail.com", "name": "Dana Levi"} 10 bakery sets a session cookie
The OAuth authorization-code flow. Dana's Google password is typed only at Google. The bakery receives a one-time code in the browser and swaps it for a token in a private server-to-server call, so the token itself never passes through the browser.
Session 5 · 5.5 OAuth: how "Sign in with Google" works · 3/3Book ↗

Why the roundabout design

Offer "Sign in with Google": higher conversion, no password liability. And always read the scopes.
Session 5 · 5.6 Security basics every product owner should knowBook ↗

Six ideas that catch most mistakes

"Have we reviewed against the OWASP Top Ten?" is a question any engineer or AI assistant can act on.
Session 5 · 5.7 Beyond the browser: mobile, desktop, embedded · 1/3Book ↗

Where the front end runs

KindFront end runsBuilt withDistributed
Web appBrowserHTML, CSS, JavaScriptA URL; updates instantly
Native mobilePhone, installedSwift (iOS), Kotlin (Android)App stores; 15 to 30% commission
Cross-platformPhone, installedReact Native, FlutterApp stores
Progressive web appBrowser, installableWeb technologiesA URL, no store
DesktopLaptop, installedNative or ElectronDownload, installer
EmbeddedInside a deviceC, C++, RustShipped in the hardware
Session 5 · 5.7 Beyond the browser: mobile, desktop, embedded · 2/3Book ↗

One back end, many clients

WebsiteHTML/CSS/JS in a browser iPhone appSwift, from the App Store Android appKotlin, from Google Play Desktop appElectron, downloaded Smart ovenembedded firmware One back end same API, same rules, same login (OAuth, tokens) JSON over HTTPS One database customers, orders Different front ends are different "faces" on the same product. Build the API once; add faces as the business needs them.
One back end, many clients. Whether the customer orders from a browser, a phone, a laptop, or the oven's own screen, the request reaches the same API and the same data. The architecture of Sessions 3 and 4 does not change.
Session 5 · 5.7 Beyond the browser: mobile, desktop, embedded · 3/3Book ↗

What this explains

Session 5 · 5.8 Where AI fits · 1/2Book ↗

An AI model is a third-party API called from your back end

Browser or app "Is the rye gluten-free?" Bakery back end 1. check who is asking 2. fetch product data from the DB 3. build the prompt 4. call Claude with the API key 5. log usage, return the answer Claude API Anthropic's servers billed per token prompt + key answer The API key and the model call live on the server. The browser only ever talks to your own back end.
AI in the architecture. The model is one more service the back end calls, after applying its own rules and adding its own data. Nothing about the tiers, hosting, or security changes.
Session 5 · 5.8 Where AI fits · 2/2Book ↗

Three practical consequences

Claude itself is served through exactly this architecture. Now you know what is on the other end of the request.
1 / 1Identity, Security, and Software Beyond the Browser