Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

amazon s3 for downloads how to handle security

I'm building a web application and am looking into using Amazon S3 to store user uploads.

My concern is, I dont want user A to see his download link for a document he uploaded is urltoMyS3/doc1234.pdf and try urltoMyS3/doc1235.pdf and get another users document.

The only way I can think of to do this, is to only allow the web application to connect to S3, then check if the user has access to a file on the web application, have the web app download the file, and then serve it to the client. The problem with this method is the application would have to download the file first and would inevitably slow the download process down for the user.

How is user files typically handled with Amazon S3? Or is it simply not typically used in a scenario where the files should not be public? Is there another service for something like this?

Thanks

like image 995
Kyle Avatar asked Oct 18 '12 20:10

Kyle


People also ask

How can administrators securely upload/download your data to Amazon S3?

You can securely upload/download your data to Amazon S3 via SSL endpoints using the HTTPS protocol. If you need extra security you can use the Server-Side Encryption (SSE) option to encrypt data stored at rest.

How do I get permission to download a S3 bucket?

Open the IAM console. Add a policy to the IAM user that grants the permissions to upload and download from the bucket. You can use a policy that's similar to the following: Note: For the Resource value, enter the Amazon Resource Name (ARN) for the bucket with a wildcard character to indicate the objects in the bucket.

What is the best way to protect a file in Amazon S3 against accidental delete?

To prevent or mitigate future accidental deletions, consider the following features: Enable versioning to keep historical versions of an object. Enable Cross-Region Replication of objects. Enable MFA delete to require multi-factor authentication (MFA) when deleting an object version.


2 Answers

You can do this by generating the appropriate links, see the following

https://docs.aws.amazon.com/AmazonS3/latest/dev/RESTAuthentication.html#RESTAuthenticationQueryStringAuth

like image 63
stilldodge Avatar answered Oct 05 '22 22:10

stilldodge


You can implement Query String Authentication, which will solve your problem.

Query string authentication is useful for giving HTTP or browser access to resources that would normally require authentication. The signature in the query string secures the request. Query string authentication requests require an expiration date. You can specify any future expiration time in epoch or UNIX time (number of seconds since January 1, 1970).

like image 31
Michal Klouda Avatar answered Oct 06 '22 00:10

Michal Klouda