Skip to content

Accept logout only by POST - #61

Merged
rangoDJ merged 1 commit into
mainfrom
fix/logout-post-only
Oct 10, 2026
Merged

rangoDJ merged 1 commit into
mainfrom
fix/logout-post-only

Conversation

@rangoDJ

@rangoDJ rangoDJ commented Oct 10, 2026

Copy link
Copy Markdown
Owner

Fixes #59

What changed

  • logout() is POST-only and answers 303 See Other to /login.html (so the browser follows with a GET). GET now gets 405.
  • The dashboard's Logout link is a <form method="post"> button; .logout-form { display: contents } keeps it in the header row like the other buttons.

A cross-site POST doesn't carry the SameSite=Lax cookie, so another site can no longer sign users out.

Testing

  • pytest: 249 passed, 8 skipped. New tests: GET logout is refused (405); POST logout returns 303 to the login page, clears the cookie and leaves the client signed out. Both fail without the fix.
  • Local dev server: the Logout button lines up with the Password button (same top and height), and clicking it sends POST /auth/logout → 303 See Other.

🤖 Generated with Claude Code

/auth/logout also answered GET, and the SameSite=Lax session cookie is
still sent when another site navigates there, so any page could sign the
user out. Logout is now POST-only (303 to the login page) and the
dashboard's Logout link is a form button.

Fixes #59

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rangoDJ
rangoDJ merged commit 0ed5f89 into main Oct 10, 2026
4 checks passed
@rangoDJ
rangoDJ deleted the fix/logout-post-only branch October 10, 2026 22:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Any website can log you out (GET /auth/logout)

1 participant