Skip to content

SU1: the auth app on Workers - #2

Merged
ruehowl merged 1 commit into
mainfrom
su1
Oct 29, 2026
Merged

ruehowl merged 1 commit into
mainfrom
su1

Conversation

@ruehowl

@ruehowl ruehowl commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

What

The auth app (SU-2). apps/web is Auth.js's SvelteKit example on SvelteKit 2.60.1 and Svelte 5, built by @sveltejs/adapter-cloudflare into one Worker with Static Assets. The upstream licence is ISC, © 2022-2024 Balázs Orbán, and ships as apps/web/LICENSE.

  • Kept from upstream: the pages, header, footer and the signin/signout actions. @auth/sveltekit is pinned at 1.11.3, and upstream's cookie@0 → 0.7.0 override is carried over.
  • Providers by their keys: the 26 providers are listed in src/server/providers.ts. Each one is registered only when every key it takes is set. The config is lazy, SvelteKitAuth(async (event) => …), and reads the Worker's bindings first.
  • /signin: shows a button for each connected provider. With none connected, it says so, lists GitHub's keys, and gives every provider's keys.
  • No database: sessions are Auth.js's JWT cookies, so there is no data rung (SU2).
  • AUTH_SECRET: tooling/wire/worker-secrets.mjs runs in the deploy lane's build.
    • It lists the secrets the Worker carries and generates AUTH_SECRET only if there is none.
    • If the list fails for any other reason than a missing Worker, it refuses to mint a replacement.
    • It pushes AUTH_SECRET and any provider keys that are set with wrangler secret bulk over stdin.
    • Every AUTH_* variable is unset for vite build.
    • Locally, pnpm secret:dev writes AUTH_SECRET into apps/web/.env, upstream's local file.
  • Smoke: / must render </html>, and /auth/session must answer null. Only a Worker that has its AUTH_SECRET answers it that way.

Checks

  • Locally: typecheck, lint, 18 unit tests and the build all pass.
    • The unit tests cover the providers, the bindings, the site's name and the secret step against a stand-in wrangler.
    • wrangler deploy --dry-run reports 702 KiB, 162 KiB gzipped.
  • Under wrangler dev:
    • With no secret, /auth/session fails.
    • With a secret, every page renders.
    • With GitHub's keys, signing in reaches GitHub's authorize URL with this site's callback.
  • CI: the plan job only, while the workspace is the placeholder.

Generated by Claude Code

apps/web is Auth.js's SvelteKit example (nextauthjs/sveltekit-auth-example,
ISC, © 2022-2024 Balázs Orbán; the licence is apps/web/LICENSE) on
SvelteKit 2.60.1 and Svelte 5, built by @sveltejs/adapter-cloudflare into
one Worker with Static Assets. @auth/sveltekit is pinned at 1.11.3, and
upstream's cookie@0 override is carried in pnpm-workspace.yaml.

- The example's pages, header, footer and actions. Its 26 providers are in
  src/server/providers.ts, and each is registered only when every key it
  takes is set. The configuration is built per request from the Worker's
  bindings.
- A /signin page lists the connected providers, or says that none is
  connected and which keys connect each one.
- Sessions are Auth.js's JWT cookies. There is no database.
- tooling/wire/worker-secrets.mjs runs in the deploy lane's build. It
  lists the secrets the Worker carries, generates AUTH_SECRET only if there
  is none, and refuses to mint when the list fails. It pushes AUTH_SECRET
  and any provider keys that are set with `wrangler secret bulk` over stdin.
  `pnpm secret:dev` runs the same step against apps/web/.env.
- The smoke is read-only: `/` must render and /auth/session must answer
  null.

Checks: typecheck, lint, 18 unit tests and the build are green, and
`wrangler deploy --dry-run` reports 702 KiB, 162 KiB gzipped. Under
`wrangler dev`, with no secret /auth/session fails. With a secret, every
page renders. With GitHub keys, signing in reaches GitHub's authorize URL.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019PcpNVpFBcbeiX3EHdXfmn
@ruehowl
ruehowl merged commit 3dac7c6 into main Oct 29, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants