Warn about upcoming change to AWS_DEFAULT_ACL; allow None in AWS_DEFAULT_ACL #535
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.
Background
As discussed in #381, the default setting of "public-read" for
AWS_DEFAULT_ACL
is insecure -- if a user sets up a bucket that is private by default, they should have to explicitly opt in for django-storages to override that choice and upload globally readable files. By default uploads should use the bucket's settings.@jschneier suggested in that bug that the change should be made in django-storages 2.0, since it would be a breaking change for many users.
@robatwave commented that one can currently opt into the proposed behavior by setting
AWS_DEFAULT_ACL=None
explicitly. This does not work for me; with that setting I get'NoneType' object has no attribute 'parts'
inS3Boto3StorageFile.close
.@ticosax sent a pull request last year, #429, that implements the breaking change but currently has some tests failing.
It would be great to take action on this without waiting for the decision to ship django-storages 2.0. It's likely that lots of users are currently using django-storages in a way that unintentionally leaks data -- it's not something where it's harmless to wait.
This PR
This is a change that can be made immediately without waiting for 2.0. It gets
AWS_DEFAULT_ACL=None
working, and adds a warning that the default behavior will be changing in 2.0.This PR is based on the work @ticosax did and includes 3 commits:
None
and tweaking a test. This getsAWS_DEFAULT_ACL=None
working for me.AWS_DEFAULT_ACL
setting. The warning includes instructions for how (and why) a user can either explicitly retain the existing behavior if it's actually what they want, withAWS_DEFAULT_ACL="public-read"
, or prepare for 2.0 by opting into the new behavior withAWS_DEFAULT_ACL=None
.