-
-
Notifications
You must be signed in to change notification settings - Fork 536
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Disable multipart uploads by default (#3645)
* Disable multipart uploads by default * Document the new option * Stop disabling Django's CSRF protection by default * Document breaking changes * Add release file * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Bump date * Test * Add tweet file * Shorter tweet --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Patrick Arminio <[email protected]>
- Loading branch information
1 parent
18f0f5d
commit 37265b2
Showing
40 changed files
with
207 additions
and
44 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Release type: minor | ||
|
||
Starting with this release, multipart uploads are disabled by default and Strawberry Django view is no longer implicitly exempted from Django's CSRF protection. | ||
Both changes relieve users from implicit security implications inherited from the GraphQL multipart request specification which was enabled in Strawberry by default. | ||
|
||
These are breaking changes if you are using multipart uploads OR the Strawberry Django view. | ||
Migrations guides including further information are available on the Strawberry website. |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
🆕 Release $version is out! Thanks to $contributor 👏 | ||
|
||
We've made some important security changes regarding file uploads and CSRF in | ||
Django. | ||
|
||
Check out our migration guides if you're using multipart or Django view. | ||
|
||
👇 $release_url |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
--- | ||
title: 0.243.0 Breaking Changes | ||
slug: breaking-changes/0.243.0 | ||
--- | ||
|
||
# v0.240.0 Breaking Changes | ||
|
||
Release v0.240.0 comes with two breaking changes regarding multipart file | ||
uploads and Django CSRF protection. | ||
|
||
## Multipart uploads disabled by default | ||
|
||
Previously, support for uploads via the | ||
[GraphQL multipart request specification](https://github.com/jaydenseric/graphql-multipart-request-spec) | ||
was enabled by default. This implicitly required Strawberry users to consider | ||
the | ||
[security implications outlined in the GraphQL Multipart Request Specification](https://github.com/jaydenseric/graphql-multipart-request-spec/blob/master/readme.md#security). | ||
Given that most Strawberry users were likely not aware of this, we're making | ||
multipart file upload support stictly opt-in via a new | ||
`multipart_uploads_enabled` view settings. | ||
|
||
To enable multipart upload support for your Strawberry view integration, please | ||
follow the updated integration guides and enable appropriate security | ||
measurements for your server. | ||
|
||
## Django CSRF protection enabled | ||
|
||
Previously, the Strawberry Django view integration was internally exempted from | ||
Django's built-in CSRF protection (i.e, the `CsrfViewMiddleware` middleware). | ||
While this is how many GraphQL APIs operate, implicitly addded exemptions can | ||
lead to security vulnerabilities. Instead, we delegate the decision of adding an | ||
CSRF exemption to users now. | ||
|
||
Note that having the CSRF protection enabled on your Strawberry Django view | ||
potentially requires all your clients to send an CSRF token with every request. | ||
You can learn more about this in the official Django | ||
[Cross Site Request Forgery protection documentation](https://docs.djangoproject.com/en/dev/ref/csrf/). | ||
|
||
To restore the behaviour of the integration before this release, you can add the | ||
`csrf_exempt` decorator provided by Django yourself: | ||
|
||
```python | ||
from django.urls import path | ||
from django.views.decorators.csrf import csrf_exempt | ||
|
||
from strawberry.django.views import GraphQLView | ||
|
||
from api.schema import schema | ||
|
||
urlpatterns = [ | ||
path("graphql/", csrf_exempt(GraphQLView.as_view(schema=schema))), | ||
] | ||
``` |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.