Reputation: 1414
We are facing a use case where we need to store confidential images of the user on S3. Now as S3 is accessible over HTTP and if we give a read access to the objects they will be available to the world via web. We need to restrict the images/files only to that user. So the possible solutions we thought are:
http://bucket.s3.amazon.com/clients/img/j84jaljvkeh774d/myimage.jpg
In the first one we may not get the cloudfront or cdn benefits as it might involve a independent proxy server.
The second one,is in a way secure as it would be difficult to predict the keyname,if its unique to a user.
Using ACl and bucket policies won't completely solve the problem.
Also,if we write a policy which restricts IP addresses, the mobile app which uses the same API backend would end up not working as those would have requests originating from different IP's.
We know we cannot completely secure them,but do we have an approach to deal with such a scenario?Please share your inputs.
Upvotes: 3
Views: 694
Reputation: 13723
You want to use presigned URLs for this. You generate those for a fixed (short) period of time, for a specific user. If this URL gets leaked, it doesn't matter – because they expire.
If you do that, everything in your bucket can remain private.
If you're using Ruby, here's a glimpse how you'd do this: https://github.com/aws/aws-sdk-core-ruby/commit/f946c113ff24d97673d8ffd43cb4012c8e211992
Upvotes: 2
Reputation: 1201
This could be achieved by option one.
Upvotes: 2