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

Warn about upcoming change to AWS_DEFAULT_ACL; allow None in AWS_DEFAULT_ACL #535

Merged
merged 3 commits into from
Aug 8, 2018

Conversation

jcushman
Copy link
Contributor

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' in S3Boto3StorageFile.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:

  • (1) Incorporate the changes from @ticosax in Don't override default ACL already configured on AWS side. #429.
  • (2) Fix two issues with that PR, adding a second check for None and tweaking a test. This gets AWS_DEFAULT_ACL=None working for me.
  • (3) Back out the breaking changes from Don't override default ACL already configured on AWS side. #429 for now, and instead print a warning if the user has no explicit 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, with AWS_DEFAULT_ACL="public-read", or prepare for 2.0 by opting into the new behavior with AWS_DEFAULT_ACL=None.

ticosax and others added 2 commits July 18, 2018 10:42
If bucket already exists, do not try to override permissions of objects.

same for bucket creation, let defaults configured on AWS takes precedence.
@ticosax
Copy link
Contributor

ticosax commented Jul 19, 2018

well done

@jcushman
Copy link
Contributor Author

jcushman commented Aug 7, 2018

@sww314, just a nudge -- is there anything else I can do to assist with getting this merged? Thanks!

@sww314 sww314 requested a review from jschneier August 7, 2018 20:06
@sww314
Copy link
Contributor

sww314 commented Aug 7, 2018

@jcushman Looks ok to me, but I am not actively using the AWS storages, so I would like someone that uses the boto/boto3 to chime in.

@sww314 sww314 added the s3boto label Aug 8, 2018
@jschneier
Copy link
Owner

Thanks so much. I've come to the conclusion that my decision earlier on this was wrong and it should have been addressed immediately. Going to merge and cut 2.0 with this fixed on Friday. For some of the other changes I want to make we can wait to 3.0 which can always come quicker.

@jschneier
Copy link
Owner

Should we also be warning on the s3boto and gs backends? I know those are legacy but I'm not going to remove them in 1.6.7

@jschneier jschneier merged commit 8771ae7 into jschneier:master Aug 8, 2018
bowans added a commit to bowans/tsyc-django that referenced this pull request Sep 20, 2018
@jxltom jxltom mentioned this pull request Nov 27, 2018
7 tasks
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.

4 participants