Skip to content

fix(recipes): auth-gated recipes sign in through the real auth extension (#1001) - #1012

Merged
jimhoyd merged 1 commit into
mainfrom
claude/recipes-real-auth-1001
Sep 30, 2026
Merged

jimhoyd merged 1 commit into
mainfrom
claude/recipes-real-auth-1001

Conversation

@jimhoyd

@jimhoyd jimhoyd commented Sep 30, 2026

Copy link
Copy Markdown
Collaborator

Fixes #1001

What changed

The five recipes behind auth: true (store-booking, store-credits, store-approval, authenticated-json-api, protected-download) now run against the real auth extension (Better Auth). The Bearer <id> stand-in principal is gone everywhere, including the protocol example in authenticated-json-api. There is one path, the real extension. There are no external users, so nothing is kept for back-compat.

  • The auth mount. The recipe's urlcode.yaml does need it: auth refuses activation unless it serves exactly one mount. Each recipe therefore carries routes/auth.yaml, byte-for-byte what urlcode extensions add auth writes, via includes: [routes/auth.yaml]. The recipe's urlcode.yaml and tests copy unchanged into a site created with init + extensions add auth store, which already has that file. Route counts went up by one (2/3/5/2/2).
  • Accounts. tests/seed.json declares the synthetic accounts under auth.users with fixed ids, plus store.members.
  • Fixtures.
    • Callers sign in through POST /api/auth/sign-in/email inside steps. Each sign-in asserts expectJson {"/user/id": ...}, and the cookie jar keeps the session.
    • One asserted GET /api/auth/get-session covers the mount's GET, so audit is ready with nothing uncovered.
    • Steps were reordered so each run changes caller only a few times: 5 sign-ins for booking, 7 for credits, 7 for approval. Better Auth allows 10 per minute per client.
    • Anonymous 401s and cross-origin 403s now assert the gate's JSON body.
  • authenticated-json-api now returns context.capabilities.auth.identity.userId. It also signs out, and the fixtures assert the 401 that follows.
  • Tests.
    • packages/store/test/recipes.test.ts and plumbing.test.ts compose the real auth() and store(), as a site's host.mjs does. Counterexample YAML and credits-retries.json are updated to match.
    • The new packages/auth/test/recipes.test.ts runs the two non-store recipes through the CLI: validate, test twice, audit ready. It also keeps the [Bug]: authentication recipe automatically repins revisions while promising an explicit review gate #784 revision-pin checks: with no pin the command refuses, and an edit after review gives Extension revision pin mismatch: auth.
    • Root test/recipes.test.ts skips auth-extension recipes; it drops the fixture registry and its two stand-in tests.
  • Docs. Updated the recipe READMEs and recipe.yamls, docs/RECIPES.md, llms.txt (sign-in expectJson plus a get-session case cover the mount), and the regenerated llms-full.txt.
  • npm run measure:plumbing. Both sides gained the includes line. Scheduling is now 51/0 vs 50/139 (physical 60/219), and credits 52/0 vs 51/186 (physical 64/274). Code removed is unchanged. docs/FRAMEWORK.md is updated.
  • Package budgets. Core went over its entry limit: 544 entries against 542, from the new routes/auth.yaml and seed.json files. Per the policy in scripts/package-audit.ts, every package was re-measured on Node 26.10 and all limits were reset, with the baseline comment updated.

Evidence

  • npm run verify: pass (local, macOS, Node 26.10).
  • npm run test:package: pass.

Not done / limitations

  • There is still no recipes add --into <site>, which the issue offered as an alternative. The READMEs describe copying the files into app/ and setting expectRoutes in app/tests/audit.json.
  • Not checked on the MCP search_recipes path, beyond the shared catalog.
  • validate --local-review logs a Better Auth "Could not validate the database schema" line on stderr but still passes. This predates this change.

🤖 Generated with Claude Code

…ion (#1001)

The store-booking, store-credits, store-approval, authenticated-json-api and
protected-download recipes no longer depend on a Bearer stand-in principal.
Each carries the auth mount (routes/auth.yaml, exactly as `urlcode extensions
add auth` writes it; the extension serves exactly one mount), seeds synthetic
accounts and memberships in tests/seed.json, and its fixtures sign in through
POST /api/auth/sign-in/email in `steps`, asserting /user/id, with an asserted
GET /api/auth/get-session so the audit counts the auth mount covered. The
recipes' urlcode.yaml and tests copy unchanged into a site created with
`init` and `extensions add auth store`.

packages/store/test (recipes, plumbing) and the new packages/auth/test/
recipes.test.ts run them through the CLI with the real auth extension:
validate, test twice and audit ready. The authenticated-json-api function now
reads the signed-in user id. Plumbing counts and package budgets re-measured.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant