I found this - http://docs.aws.amazon.com/AmazonS3/latest/dev/AuthUsingTempFederationTokenRuby.html and tried it. It seems to work. Paraphrasing code from a document -
# Start a session with restricted permissions. sts = AWS::STS.new() policy = AWS::STS::Policy.new policy.allow( :actions => ["s3:ListBucket"], :resources => "arn:aws:s3:::#{bucket_name}" ).condition.add(:like, :referer, "domain.com") session = sts.new_federated_session( 'User1', :policy => policy, :duration => 2*60*60)
Thus, the policy we create may have an IP address from which the client downloads and / or may be the aws: Referer field set for my application domain. I think this provides at least one level of obstacles to your resource. I get this, the IP address or referent can be easily faked. But this is better than no defense at all.
source share