fix[faustwp-core]: (#2313) add security flags to removeCookie()#2314
Open
latenighthackathon wants to merge 2 commits intowpengine:canaryfrom
Open
fix[faustwp-core]: (#2313) add security flags to removeCookie()#2314latenighthackathon wants to merge 2 commits intowpengine:canaryfrom
latenighthackathon wants to merge 2 commits intowpengine:canaryfrom
Conversation
removeCookie() expires the refresh token cookie with only the expires attribute, missing the path, sameSite, secure, and httpOnly flags that setCookie() uses when setting it. Without a matching path: '/', the browser may not delete the correct cookie on logout. Add the same security attributes used in setRefreshToken() so the browser correctly identifies and expires the target cookie. Closes wpengine#2313
|
Currently, we do not support the creation of preview deployments based on changes coming from forked repositories. |
🦋 Changeset detectedLatest commit: 8c2f67b The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Fran-A-Dev
approved these changes
Apr 4, 2026
Contributor
Fran-A-Dev
left a comment
There was a problem hiding this comment.
LGTM, I don't think the original cookie is ever set with domain attribute anywhere else. This looks good.
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.
Description
removeCookie()inpackages/faustwp-core/src/server/auth/cookie.tsexpires the refresh token cookie with onlyexpires: new Date(0), missing thepath,sameSite,secure, andhttpOnlyflags thatsetCookie()uses when setting it.Per RFC 6265, a
Set-Cookieheader without apathattribute defaults to the current request path. If the logout request comes from a different path than/, the browser won't match and delete the original cookie — it persists after what the application considers a successful logout.Before
After
These flags match the attributes used in
setRefreshToken()(token.ts:51-58).Related Issues
Closes #2313
Testing
Confirm the issue (before the fix)
1. Verify
removeCookie()is missing security flags:2. Compare with
setCookie()which has the correct flags:Confirm the fix
3. Verify
removeCookie()now includes all security flags:4. Verify flags match the setCookie() call in token.ts:
Run the test suite
JS tests — confirms no regressions: