docs: modernize CSRF guidance for SameSite era - #124
Merged
Conversation
Explicit SameSite=Lax/Strict on the session cookie plus no-mutations- on-GET stops classic cross-site form CSRF in modern browsers; recommend a Sec-Fetch-Site check as defense-in-depth (subdomains are same-site) and demote token middleware to an if-you-use-it-anyway note.
Go 1.25 stdlib ships the Sec-Fetch-Site guard (with Origin fallback, trusted origins, and bypass patterns) — recommend wrapping the handler instead of hand-rolling middleware.
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.
Follow-up to #123. The README's htmx CSRF note prescribed token middleware as the default. Modern guidance:
SameSite=Lax/Strictsession cookie + never mutating on GET stops classic cross-site form CSRF in all modern browsers (explicit matters: default-Lax carries the Chrome Lax+POST grace window and isn't uniform across Safari/Firefox).Sec-Fetch-Site, a few lines of BYO middleware, which fits hime's philosophy better than token machinery.hx-headerswiring and the localStorage-snapshot caveat.