Repository navigation
middleware: csrf token for first requests, verified auth, 0.5.0 - #67
Merged
Merged
Conversation
This was referenced Nov 22, 2026
carlrafting
force-pushed
the
claude/middleware-open-issues
branch
3 times, most recently
from
November 23, 2026 08:33
30271eb to
9aa8d79
Compare
Resolve the limitations left open after the previous fixes. - csrf: add csrfToken(request) so a handler can embed the token in a form or page, including on a visitor's first request, when the cookie has not reached the browser yet. The middleware now issues the token before running the handler and records it against the request. - auth: `verify` is now required and decides whether the cookie value is acceptable, instead of trusting that a cookie named `authenticated` exists. The cookie name is configurable. Requests to the sign-in path still bypass the check. This is a breaking change to a module that is not exported and not imported elsewhere in the repo. - readme: make the code samples complete so `deno check --doc readme.md` passes, and mark the two that cannot stand alone (the compose signature and the serve.ts file that needs a main.ts) as ignored. - Bump @stewpot/middleware to 0.5.0, since the stack helper return values and the csrf and auth behavior changed in 0.x. Point @stewpot/routes at ^0.5.0 so it keeps resolving the workspace member. routes 0.1.5 is unpublished (JSR has 0.1.4), so it needs no further bump. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
carlrafting
force-pushed
the
claude/middleware-open-issues
branch
from
November 23, 2026 08:34
9aa8d79 to
773af38
Compare
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.
Summary
Resolves the limitations left open after #66. Stacked on #66, which sits on #65 and #64, so the diff here is one commit. Merge #64, then #65, then #66, then this; each should retarget to
devas the branch below it is deleted.csrf: newcsrfToken(request)helper so a handler can embed the token in a form or page, including on a visitor's first request, before thehttpOnlycookie has reached the browser. The middleware now issues the token before running the handler and records it against theRequestobject. Call it with the sameRequestthe middleware received.auth:verify(value, request)is now required and decides whether the cookie value is acceptable, instead of trusting that a cookie namedauthenticatedexists. The cookie name is configurable (cookie, defaultauthenticated). Requests to the sign-in path still bypass the check;verifyis only called when the cookie is present.deno check --doc readme.mdpasses. The two that cannot stand alone (thecomposesignature and theserve.tsfile that needs amain.ts) are markedignore.@stewpot/middleware0.4.1 to 0.5.0, since the helper return values and thecsrfandauthbehavior changed.@stewpot/routesnow depends on^0.5.0;^0.4.1would no longer match the workspace member, which would bring back the "workspace member was not used" warning.Things to know
auth's new required option breaks the old call shape. The module is not exported and nothing in the repo imports it.middleware0.4.1 androutes0.1.4, soroutes0.1.5 is still unpublished and needs no further bump.auth,csrfandsessionare still not in the package exports. Exporting them would add real public API, so that is left for a separate decision.format,lintanddoc lint (feeds)checks stay red.Test plan
deno fmt --check,deno lint,deno doc --lint(entry points),deno check,deno check --doc readme.mdanddeno task testpass inmiddleware/(57 tests)deno check, plus theroutesandmanagetests, pass; no "workspace member" warning forroutestestlegs andtype checkblocking;formatandlintshould report nothing formiddleware/(other packages may still fail them, advisory)🤖 Generated with Claude Code