Files
heidi/app/api/auth/[...nextauth]
CatoandClaude Opus 5 304dcde052 feat(auth): sign in with OrangeCat — Heidi keeps no users table (#11)
Heidi's portal needs learners, tutors who can be paid, and study
groups. That is identity, economy and public presence — every one of
which OrangeCat already owns and already serves to two other
consumers (FleetCrown since 2026-07, Solon since).

So Heidi federates instead of building its own. No users table, no
password, no reset flow, no session table: the JWT carries the
OrangeCat actor id and nothing else is stored here. A users table you
do not have is a users table that cannot leak.

This is the identity-bridge instruction applied to a second app —
"Do NOT build profiles, walls, or messaging inside FleetCrown" —
because rebuilding a user table, a payments rail and a profile
directory inside Heidi would be that same mistake in a different repo.

WHAT LANDED

- lib/auth/provider.ts — the OIDC provider, deliberately free of any
  next-auth import so its two load-bearing quirks are asserted by
  node:test rather than remembered. Both were paid for once already by
  FleetCrown: OrangeCat's token endpoint accepts ONLY
  client_secret_post (Auth.js defaults to basic, which OC rejects with
  a 400 reading "client_id is required" — pointing at the wrong
  problem), and PKCE is required even for a confidential client.
- lib/auth/index.ts — NextAuth wiring, JWT strategy, no adapter.
- Account control in the header, portal page, auth error page, all six
  languages. Server actions, so signing in and out need no client JS —
  which matters for the one control that has to work on a tram.
- The portal is noindex, and ROUTES gained `indexed` so the sitemap
  cannot advertise a page whose own robots meta forbids it.

next-auth is pinned EXACTLY, not with a caret. A caret on a prerelease
is why kivvi sits on beta.16 while the rest of the fleet is on
beta.32 — the range silently spans betas.

The provider is env-gated: with no client pair configured the control
renders nothing rather than a button that dead-ends at the code
exchange. A half-configured provider that looks present is worse than
an absent one.

OPERATIONAL

Client registered in OrangeCat (bitbaum/orangecat#977) with identity
scopes only. AUTH_URL is pinned in the box env — without it next-auth
builds callbacks against the internal origin behind Caddy and ships
localhost URLs to users, which is the exact class the fleet's
nextauth-origin-audit.mjs exists to catch after one app shipped it
twice.


Claude-Session: https://claude.ai/code/session_01BUfvtBc4ycbYRRjb9eBmuB

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-11 14:10:48 -07:00
..