Skip to content

fix: Refresh Panel globals after logout - #8508

Merged
distantnative merged 3 commits into
develop-patchfrom
fix/8502-csrf-after-logout
Sep 22, 2026
Merged

distantnative merged 3 commits into
develop-patchfrom
fix/8502-csrf-after-logout

Conversation

@distantnative

@distantnative distantnative commented Sep 22, 2026 •

Copy link
Copy Markdown
Member

Review

  • Rough pass
  • Manual testing

Description

Auth::logout() removes kirby.csrf from the session since v5.6.0. The logout view then redirects with Panel::go('login'), which the Panel follows in place, so the browser keeps $system.csrf from before the logout while the session no longer has a token at all.

The logout view now asks for the globals it invalidated: Panel::go('login?_globals=$system,$translation').

I didn't go with Panel::go(url: 'login', refresh: 0): Response::refresh() sends a 302 with a Refresh header and no Location, so the Panel's fetch can't follow it, falls through to RedirectError, and bounces the browser back to /panel/logout.

Changelog

🐛 Bug fixes

For review team

  • Add changes & docs to release notes draft in Notion

@distantnative distantnative added this to the 5.6.1 milestone Sep 22, 2026
@distantnative distantnative self-assigned this Sep 22, 2026
@distantnative
distantnative marked this pull request as ready for review September 22, 2026 10:20
@distantnative
distantnative requested a review from a team September 22, 2026 10:20

@afbora afbora left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue happens on code login: the logout() call inside verifyChallenge() removes the token, but LoginCodeForm only calls this.$reload() without asking for globals. Changing it to this.$reload({ globals: ["$system", "$translation"] }) like in LoginForm fixes it.

@distantnative

Copy link
Copy Markdown
Member Author

@afbora Added a fix for that too

@afbora afbora left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might want to add a regression test for LoginCodeForm. Still LGTM anyway 👍

@distantnative

Copy link
Copy Markdown
Member Author

@afbora I will look into that for v6 which has rewritten that code completely, so the merge forward will be interesting anyways.

@distantnative
distantnative merged commit f857d6c into develop-patch Sep 22, 2026
7 checks passed
@distantnative
distantnative deleted the fix/8502-csrf-after-logout branch September 22, 2026 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

"Invalid CSRF token" when logging back in after logging out of the Panel

2 participants