Skip to content

fix: Invoke backend logout API on logout button click to prevent broken authentication#6820

Open
itsmahbub wants to merge 2 commits intoFlagsmith:mainfrom
itsmahbub:fix/logout-api-not-called-on-logout
Open

fix: Invoke backend logout API on logout button click to prevent broken authentication#6820
itsmahbub wants to merge 2 commits intoFlagsmith:mainfrom
itsmahbub:fix/logout-api-not-called-on-logout

Conversation

@itsmahbub
Copy link

@itsmahbub itsmahbub commented Mar 2, 2026

Thanks for submitting a PR! Please check the boxes below:

  • I have read the Contributing Guide.
  • I have added information to docs/ if required so people know about the feature.
  • I have filled in the "Changes" section below.
  • I have filled in the "How did you test this code" section below.

Changes

Bug

When a user logs out by clicking the "Log out" button, the logout API (/api/v1/auth/logout/) is not called. As a result, the session token is not invalidated and remains usable for API requests even after user logs out. When the user logs in again, the same token is reused instead of issuing a new one. If a token is leaked, an attacker may continue using the token indefinitely, even after the user logs out.

Solution

Call to logout API is conditional on a configuration variable named Project.cookieAuthEnabled (https://github.com/Flagsmith/flagsmith/blob/main/frontend/common/stores/account-store.js#L359). Logout button click is supposed to clean up the session token in both frontend and backend, not just frontend. To prevent session token persistence after logout, we need to call the logout functionality in backend irrespective of configuration, otherwise, the logout process will remain partial.

How did you test this code?

Before fixing

There is no call to logout API when logout button is clicked.

Screenshot 2026-03-02 at 12 49 24 PM

As a result, the token is not invalidated in the backend.

After applying fix

Logout API is called when logout button is clicked.

Screenshot 2026-03-02 at 1 40 29 PM

@vercel
Copy link

vercel bot commented Mar 2, 2026

Someone is attempting to deploy a commit to the Flagsmith Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions bot added the api Issue related to the REST API label Mar 2, 2026
@itsmahbub itsmahbub closed this Mar 2, 2026
@itsmahbub itsmahbub reopened this Mar 2, 2026
@github-actions github-actions bot added the front-end Issue related to the React Front End Dashboard label Mar 2, 2026
@itsmahbub itsmahbub force-pushed the fix/logout-api-not-called-on-logout branch from 5d26d87 to 212cbcc Compare March 2, 2026 19:47
@itsmahbub itsmahbub marked this pull request as ready for review March 2, 2026 19:48
@itsmahbub itsmahbub requested a review from a team as a code owner March 2, 2026 19:48
@itsmahbub itsmahbub requested review from kyle-ssg and removed request for a team March 2, 2026 19:48
@itsmahbub itsmahbub changed the title Set COOKIE_AUTH_ENABLED=true by default to prevent broken authentication Invoke backend logout API on logout button click to prevent broken authentication Mar 2, 2026
@itsmahbub itsmahbub changed the title Invoke backend logout API on logout button click to prevent broken authentication fix: Invoke backend logout API on logout button click to prevent broken authentication Mar 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api Issue related to the REST API front-end Issue related to the React Front End Dashboard

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant