vendredi 8 mai 2015

AWS S3 Bucket Policy to allow Images/Video to be served based on Referrer

Here is what I hope to achieve. I have a site that where everything is behind a login, once logged in the users can view images, video and mp3 files which are hosted on S3.

It is critical that the files are secure and private (especially from the likes of search engines).

I have the following policy set up:

{
    "Version": "2012-10-17",
    "Id": "http referer policy example",
    "Statement": [
        {
            "Sid": "Allow get requests originated from www.example.com and example.com",
            "Effect": "Allow",
            "Principal": "*",
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::mybucket/*",
            "Condition": {
                "StringLike": {
                    "aws:Referer": [
                        "http://ift.tt/1RjRwhP",
                        "http://ift.tt/1EUu9EX",
                        "http://ift.tt/1RjRwhU",
                        "http://livedomain.com/*",
                        "http://ift.tt/1EUu7wY",
                        "http://ift.tt/1RjRuqf"
                    ]
                }
            }
        }
    ]
}

Now, this works great for images, but when it comes to video (currently just using the default browser player, but I assume the same issue will come about if I used a flash player or HTML5 player) I get a 403 Forbidden error. I assume that this has something to do with the referrer.

Any ideas?




Aucun commentaire:

Enregistrer un commentaire