Repository navigation
fix(recipes): auth-gated recipes sign in through the real auth extension (#1001) - #1012
Merged
Merged
Conversation
…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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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). TheBearer <id>stand-in principal is gone everywhere, including the protocol example inauthenticated-json-api. There is one path, the real extension. There are no external users, so nothing is kept for back-compat.urlcode.yamldoes need it:authrefuses activation unless it serves exactly one mount. Each recipe therefore carriesroutes/auth.yaml, byte-for-byte whaturlcode extensions add authwrites, viaincludes: [routes/auth.yaml]. The recipe'surlcode.yamland tests copy unchanged into a site created withinit+extensions add auth store, which already has that file. Route counts went up by one (2/3/5/2/2).tests/seed.jsondeclares the synthetic accounts underauth.userswith fixed ids, plusstore.members.POST /api/auth/sign-in/emailinsidesteps. Each sign-in assertsexpectJson {"/user/id": ...}, and the cookie jar keeps the session.GET /api/auth/get-sessioncovers the mount's GET, soauditis ready with nothing uncovered.401s and cross-origin403s now assert the gate's JSON body.authenticated-json-apinow returnscontext.capabilities.auth.identity.userId. It also signs out, and the fixtures assert the401that follows.packages/store/test/recipes.test.tsandplumbing.test.tscompose the realauth()andstore(), as a site'shost.mjsdoes. Counterexample YAML andcredits-retries.jsonare updated to match.packages/auth/test/recipes.test.tsruns 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 givesExtension revision pin mismatch: auth.test/recipes.test.tsskips auth-extension recipes; it drops the fixture registry and its two stand-in tests.recipe.yamls,docs/RECIPES.md,llms.txt(sign-inexpectJsonplus aget-sessioncase cover the mount), and the regeneratedllms-full.txt.npm run measure:plumbing. Both sides gained theincludesline. 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.mdis updated.routes/auth.yamlandseed.jsonfiles. Per the policy inscripts/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
recipes add --into <site>, which the issue offered as an alternative. The READMEs describe copying the files intoapp/and settingexpectRoutesinapp/tests/audit.json.search_recipespath, beyond the shared catalog.validate --local-reviewlogs a Better Auth "Could not validate the database schema" line on stderr but still passes. This predates this change.🤖 Generated with Claude Code