-
Notifications
You must be signed in to change notification settings - Fork 994
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(dbauth-mw): Unset cookie instead of clearing #10502
Conversation
packages/auth-providers/dbAuth/middleware/src/__tests__/createDbAuthMiddleware.test.ts
Outdated
Show resolved
Hide resolved
@dthyresson will leave for you to merge just so you're aware. We were missing part of the test case here, otherwise would've caught it! |
|
||
// mwResponse gets converted to a response eventually. | ||
const finalResponse = res.toResponse() | ||
expect(finalResponse.headers.getSetCookie()).toEqual([ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expect(finalResponse.headers.getSetCookie()).toEqual([ | |
// Verify that the cookies were unset | |
expect(finalResponse.headers.getSetCookie()).toEqual([ |
// mwResponse gets converted to a response eventually. | ||
const finalResponse = res.toResponse() | ||
expect(finalResponse.headers.getSetCookie()).toEqual([ | ||
// Expired cookies here! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Expired cookies here! | |
// Expired cookies with no values |
// mwResponse gets converted to a response eventually. | ||
const finalResponse = res.toResponse() | ||
expect(finalResponse.headers.getSetCookie()).toEqual([ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be honest the code comment you had was confusing me more than it was helping me. I suggest just getting rid of it and inlining the res.toResponse()
part. I think the code speaks for itself here 🙂
// mwResponse gets converted to a response eventually. | |
const finalResponse = res.toResponse() | |
expect(finalResponse.headers.getSetCookie()).toEqual([ | |
expect(res.toResponse().headers.getSetCookie()).toEqual([ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leaving as is in favor of @Tobbe 's comments
…g-gen-mw-p2 * 'main' of github.com:redwoodjs/redwood: RSC: Add RSC+SSR smoke test to CI (#10477) fix(dbauth-mw): Use response passed in to middleware (#10516) Add redwood.toml to `yarn rw info` (#10518) chore(tests): Fix packages/web tests (#10517) fix(dbauth-mw): Unset cookie instead of clearing (#10502) chore(deps): Upgrade to React canary 20240424 (#10513) chore(deps): Upgrade to React Testing Library 14.3.1 (#10514) feat(upgrade): Use GitHub token if available when downloading patches (#10515)
Updates dbAuth middleware implementation to unset the cookies, instead of clearing them.
This fixes the case where the cookie should be removed when decryption fails.