Skip to content
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(csrf): override fetch to handle requests with CSRF token #1014

Merged
merged 1 commit into from
Oct 16, 2024

Conversation

Fallenbagel
Copy link
Owner

@Fallenbagel Fallenbagel commented Oct 16, 2024

Description

During the migration from Axios to fetch, we overlooked the fact that Axios automatically handled CSRF tokens, while fetch does not. When CSRF protection was turned on, requests were failing with an
"invalid CSRF token" error for users accessing the app even via HTTPS. This PR overrides fetch to ensure that the CSRF token is included in all requests.

@M0NsTeRRR thanks for helping me debug and find a solution!

Screenshot (if UI-related)

To-Dos

  • Successful build pnpm build
  • Translation keys pnpm i18n:extract
  • Database migration (if required)

Issues Fixed or Closed

src/utils/apiFetch.ts Fixed Show fixed Hide fixed
@Fallenbagel
Copy link
Owner Author

@all-contributors please add @M0NsTeRRR for security

Copy link
Contributor

@Fallenbagel

I've put up a pull request to add @M0NsTeRRR! 🎉

src/utils/apiFetch.ts Outdated Show resolved Hide resolved
During the migration from Axios to fetch, we overlooked the fact that Axios automatically handled
CSRF tokens, while fetch does not. When CSRF protection was turned on, requests were failing with an
"invalid CSRF token" error for users accessing the app even via HTTPS. This commit
overrides fetch to ensure that the CSRF token is included in all requests.

fix #1011
@Fallenbagel Fallenbagel changed the title fix(csrf): add a custom fetch utility to handle requests with CSRF token fix(csrf): override fetch to handle requests with CSRF token Oct 16, 2024
Copy link
Collaborator

@gauthier-th gauthier-th left a comment

Choose a reason for hiding this comment

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

lgtm

@Fallenbagel Fallenbagel merged commit 4945b54 into develop Oct 16, 2024
8 checks passed
@Fallenbagel Fallenbagel deleted the fix-csrf-protection branch October 16, 2024 23:25
@Fallenbagel
Copy link
Owner Author

🎉 This PR is included in version 2.0.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] CSRF Validation broken since 2.0.0
3 participants