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

[s3] fix disabling cloudfront signing with class variable #1334

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion storages/backends/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,8 @@ class S3Storage(CompressStorageMixin, BaseStorage):

def __init__(self, **settings):
omitted = object()
self.cloudfront_signer = settings.pop("cloudfront_signer", omitted)
if not hasattr(self, "cloudfront_signer"):
self.cloudfront_signer = settings.pop("cloudfront_signer", omitted)

super().__init__(**settings)

Expand Down
6 changes: 6 additions & 0 deletions tests/test_s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -894,6 +894,12 @@ def test_cloudfront_config(self):
storage = s3.S3Storage(cloudfront_signer=None)
self.assertIsNone(storage.cloudfront_signer)

# allow disabling cloudfront signing in subclass
class Storage(s3.S3Storage):
cloudfront_signer = None

self.assertIsNone(Storage().cloudfront_signer)

storage = s3.S3Storage(cloudfront_key_id=key_id, cloudfront_key=pem)
self.assertIsNotNone(storage.cloudfront_signer)

Expand Down