Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does S3 (using with boto and django-storages) give signed url even for public files?

This is strange. I have mix of public as well as private files. I want normal urls in public files, and signed urls in private files.

I tried to change AWS_QUERYSTRING_AUTH to False as I see by default, it's True in django-storages.

But, when I change it, my private files url is not signed (thus not accessible).

May be I am missing something here. What can be solution?

Thanks in advance.

like image 615
chhantyal Avatar asked May 27 '13 17:05

chhantyal


People also ask

What is signed URL in S3?

S3 pre-signed URLs are a form of an S3 URL that temporarily grants restricted access to a single S3 object to perform a single operation — either PUT or GET — for a predefined time limit. To break it down: It is secure — the URL is signed using an AWS access key.

How secure is S3 signed URL?

There is an access check on the S3 side but that only checks whether the signer entity is allowed to get the file. You can remove that permission but that invalidates all signed URLs. Signed URLs provide secure a way to distribute private content without streaming them through the backend.

When should I use Presigned URL S3?

All objects and buckets are private by default. However, you can use a presigned URL to optionally share objects or allow your customers/users to upload objects to buckets without AWS security credentials or permissions. You can use presigned URLs to generate a URL that can be used to access your Amazon S3 buckets.

How long is S3 Presigned URL valid for?

In the Amazon S3 console, the maximum expiration time for a presigned URL is 12 hours from the time of creation.


2 Answers

AWS_QUERYSTRING_AUTH sets the default behavior, but you can override it when you create an instance of S3BotoStorage, by passing in an additional argument to the initializer:

S3BotoStorage(bucket="foo", querystring_auth=False)

So if you have one bucket private and another bucket public, you can set the querystring_auth argument appropriately and get your desired behavior.

like image 146
user2433326 Avatar answered Sep 29 '22 14:09

user2433326


put this in your settings.py

AWS_QUERYSTRING_AUTH = False
like image 38
Algorithmatic Avatar answered Sep 29 '22 14:09

Algorithmatic