Hey, @satish.sreenivasan
Thanks for the question.
Please note that the requested feature is related to the Bucket Policies and Permissions, which should be configured within your AWS console.
In the ‘Bucket Policy’ area you can configure the rules for security and privacy via Bucket Policy. Take a look at the “Action”, “Resource” and “Condition” fields where we grant access to reading the objects from our bucket. In this case, we are granting read file access only to users from our application domain, so if a user gets an image URL and tries to open it in a new tab or a new window, the bucket policy will block this request because we stated in the privacy rules that the link can be opened only from our domain:
Here’s a code example (JSON):
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AddPerm",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::YOUR-BUCKET-NAME/*",
"Condition": {
"StringLike": {
"aws:Referer": "https://zeroqode-demo-02.bubbleapps.io/*"
}
}
},
{
"Sid": "AddPerm2",
"Effect": "Allow",
"Principal": "*",
"Action": "*",
"Resource": "arn:aws:s3:::YOUR-BUCKET-NAME/*"
}
]
}
You can use the following JSON for CORS policy to allow access from your domain only (change the allowed origin to the URL of your app starting with https://)
[
{
"AllowedHeaders": [
"*"
],
"AllowedMethods": [
"GET",
"PUT",
"DELETE",
"POST"
],
"AllowedOrigins": [
"https://yourdomain.com",
"https://yourdomain.bubbleapps.io"
],
"ExposeHeaders": [
"ETag"
],
"MaxAgeSeconds": 30000
}
]
You can find more Bucket Policy examples here. Feel free to try out other rules in order to improve your bucket security.
Note that you can set any policies, which would be convenient for your application.
Hope it will be helpful for you.
Best regards,