Search code examples
google-cloud-platformgoogle-cloud-storage

How do I make an object in Google Cloud Storage accessible via a link but require a key or some other form of verification to access it?


I am creating an application that requires a file to be retrived from a Google Cloud Storage bucket. Right now, I have the file's public access set to true so I can access it via URL.

Is it possible to still access the file via URL, but require some sort of authentication in the form of a key etc.?

I have looked through how IAM permissions work; however, I am not confident in my ability to use such tools proficiently yet.


Solution

  • That's not currently available.

    One possible workaround would be to write your own small service that accepts whatever custom authorization or keys you like and then vends a short-lived signed URL as a redirection. So the user would send GET to https://yourservice.com/download?magicKey=12345, and then your service would evaluate it and maybe reply with a 304 to https://storage.googleapis.com/yourbucket/yourobject?elaborateSignedUrl, with the signed URL limited to just a minute or two of validity. This would solve your problem but would require writing and maintaining the URL vending service.