Conversation
The /logout route was a GET, which is semantically incorrect for a state-mutating operation (session destruction). This also meant the CSRF token was carried in the query string, leaking it to server logs, browser history and Referer headers. Changes: - GET /logout (new route name: logoutPage) shows a no-JS confirmation page only — it no longer performs any logout action - POST /logout (route name: logout) validates the CSRF token from the request body and performs the actual logout - LogOutViewController handles the GET confirmation page - LogOutController now handles POST only and reads the token from the parsed body instead of the query string - Session.ts submits a hidden form via POST instead of navigating via window.location.href - log-out.blade.php uses a POST form with a hidden token field instead of a plain link Closes #4427 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The CSRF middleware checks for `csrfToken` in the body or `X-CSRF-Token` header. The form and Session.ts were sending `token`, causing a 400 "inactive for too long" error on logout. - Rename the hidden form field from `token` to `csrfToken` (blade view) - Rename the JS field from `token` to `csrfToken` (Session.ts) - Remove the now-redundant manual token check from LogOutController — the CSRF middleware already validates the token before the controller runs - Update tests accordingly Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
imorland
added a commit
to flarum/docs
that referenced
this pull request
Mar 14, 2026
…#4448) The /logout route is now a POST action. The GET route is renamed to logoutPage and only shows a no-JS confirmation page. Extension authors generating logout URLs or submitting logout requests directly need to update their code. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Member
Author
|
Docs: flarum/docs#510 |
imorland
added a commit
to flarum/docs
that referenced
this pull request
Mar 14, 2026
…#4448) (#510) The /logout route is now a POST action. The GET route is renamed to logoutPage and only shows a no-JS confirmation page. Extension authors generating logout URLs or submitting logout requests directly need to update their code. Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
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
GET /logoutnow only shows a no-JS confirmation page (LogOutViewController) — it never performs a logoutPOST /logoutis the new action endpoint (LogOutController) — reads the CSRF token from the request body and performs the logoutSession.tsnow submits a hidden form via POST instead of navigating viawindow.location.hreflog-out.blade.php) now renders a<form method="POST">with a hidden token field instead of an<a>linkWhy:
GETrequests should be side-effect free; session destruction is a state mutationRefererheadersCloses #4427
Test plan
LogoutTest.phpcovering: guest POST redirects, wrong/missing token falls back to confirmation page, valid token logs out and deletes the access token, safe return URL is honoured, external return URL is blocked, GET shows confirmation page with POST form, GET does not destroy any tokens/logoutdirectly (no JS), verify the confirmation page shows a button that works🤖 Generated with Claude Code