fix: Invoke backend logout API on logout button click to prevent broken authentication#6820
Open
itsmahbub wants to merge 2 commits intoFlagsmith:mainfrom
Open
fix: Invoke backend logout API on logout button click to prevent broken authentication#6820itsmahbub wants to merge 2 commits intoFlagsmith:mainfrom
itsmahbub wants to merge 2 commits intoFlagsmith:mainfrom
Conversation
|
Someone is attempting to deploy a commit to the Flagsmith Team on Vercel. A member of the Team first needs to authorize it. |
5d26d87 to
212cbcc
Compare
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.
Thanks for submitting a PR! Please check the boxes below:
docs/if required so people know about the feature.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.
As a result, the token is not invalidated in the backend.
After applying fix
Logout API is called when logout button is clicked.