Reputation: 265
I have a Google Cloud Storage bucket with images that I want to serve to users of my website. The public URL is something like this:
https://storage.googleapis.com/example-bucket/filename.jpg
So my website can easily access it, and any random internet user can enter the URL in a browser directly to access it.
Is it possible, via Google Cloud, to restrict this so that if my website tries to access the file, it succeeds, but if a random user tries to enter the URL into a browser window, they get denied?
Cloud Storage lets us set CORS policies, but they only apply for the XML API: https://cloud.google.com/storage/docs/cross-origin#server-side-support
Is it possible to restrict this via a Load Balancer, Cloud Armor, or Cloud CDN?
FYI, let's say my website is accessing it from the DOM directly, like this:
<html>
<body>
<img src="https://storage.googleapis.com/example-bucket/filename.jpg"></img>
</body
</html>
Upvotes: 1
Views: 1413
Reputation: 4069
Based on your use-case. Google Cloud Storage has no mechanism as of now to allow read but restrict download. Once the image/file has been set to public, any random user/website with the URL can read or download the file.
I would suggest:
You could also check this blog on how to control access to Google Cloud Storage.
Upvotes: 1