Last active
November 25, 2022 18:24
-
-
Save mikesprague/5881937 to your computer and use it in GitHub Desktop.
AWS: Bucket Policy Example (Allow Get by Referer)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Version": "2008-10-17", | |
"Id": "http referer policy example", | |
"Statement": [ | |
{ | |
"Sid": "Allow get requests from certain domains (including local development)", | |
"Effect": "Allow", | |
"Principal": "*", | |
"Action": "s3:GetObject", | |
"Resource": "arn:aws:s3:::bucket-name-here/*", | |
"Condition": { | |
"StringLike": { | |
"aws:Referer": [ | |
"http://sub1.domain.com/*", | |
"https://sub1.domain.com/*", | |
"http://domain.com/*", | |
"https://*.domain.dev/*", | |
"https://*.domain.com/*", | |
"http://sub1.domain.dev/*", | |
"https://sub1.domain.dev/*", | |
"https://domain.com/*", | |
"http://s3.amazonaws.com/*", | |
"http://*.domain.com/*", | |
"http://app-name.herokuapp.com/*", | |
"https://app-name.herokuapp.com/*", | |
"https://s3.amazonaws.com/*", | |
"http://*.domain.dev/*", | |
"http://localhost*/*", | |
"http://localhost:*/*", | |
"https://localhost*/*", | |
"https://localhost:*/*" | |
] | |
} | |
} | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How can i set referrer property when i use the bucket download URL from Xamarin mobile app?
I have used below snippet, but it not set the referrer, getting forbidden error.
string downloadFilePath = "https://s3.amazonaws.com/test-website-content/downloads/jQuery_Succinctly.pdf";
HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(downloadFilePath);
httpWebRequest.Referer="http://localhost";
HttpWebResponse httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse();
Please help me to resolve this,