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

Disable CSRF protection for JSON requests #449

Merged
merged 1 commit into from
Nov 12, 2024

Conversation

janko
Copy link
Contributor

@janko janko commented Nov 12, 2024

Currently, CSRF protection is only disabled for JWT requests, as those use token-based instead of cookie-based authentication. However, JSON APIs that require Content-Type: application/json and have reasonable CORS restrictions don't appear to be vulnerable to CSRF attacks.

Since handling CSRF tokens isn't trivial to do on the client side, we can reduce friction by disabling CSRF protection by default for all JSON requests (including JWT).

This is a follow-up to the discussion in #448.

Currently, CSRF protection is only disabled for JWT requests, which use
token-based instead of cookie-based authentication. However, JSON APIs
that require `Content-Type: application/json` and have reasonable CORS
restrictions don't appear to be vulnerable to CSRF attacks.

Since handling CSRF tokens isn't trivial to do on the client side, we
can reduce friction by disabling CSRF protection by default for all
JSON requests (including JWT).
@jeremyevans
Copy link
Owner

This looks great, thank you for working on it. I should have time to test and merge this later today.

@jeremyevans jeremyevans merged commit 3068065 into jeremyevans:master Nov 12, 2024
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants