[Django]-Signature/Expires/Access Key ID appearing in URL Params. Django/Boto/S3

78👍

Use: AWS_QUERYSTRING_AUTH = False

👤maggon

5👍

The extra parameters that are being added are there to implement Query String Authentication. This allows you to pre-sign the URL to private resources stored in S3. As long as someone has the pre-signed URL (and it hasn’t expired) they will be able to access these resources even though they are not publicly readable.

Without the extra parameters, there is no way to provide public access to these private S3 resources.

5👍

Works for me:
AWS_QUERYSTRING_AUTH = False

using this https://github.com/mstarinteractive/django-s3storage

from myapp.s3storage import S3BotoStorage
from django.contrib.staticfiles.storage import CachedFilesMixin


class CachedStaticS3BotoStorage(CachedFilesMixin, S3BotoStorage):

    """Extends S3BotoStorage to save static files with hashed filenames."""
    pass
StaticRootS3BotoStorage = lambda: CachedStaticS3BotoStorage(location='static')

0👍

It’s weird behaviour:
Google Docs previewer will work and display a preview without the parameters, but will say no preview available if boto appends the signature.

<iframe src="{% trans "https://docs.google.com/viewer?embedded=true&amp;url=" %}{{ document.file.url }}" width="451" height="390" style="border: none;"></iframe>

I must be missing something.

Leave a comment