0

It's been two days since I have been working on generating a custom URL to access cloud storage private contents.

  • I have created CDN and load balancer to access the bucket.
  • I have a CDN IP address to access the files.

When I grant a file in storage bucket as public I can able to access using CDN IP. Example: https://<CDN IP Address>/filename.pdf

Since all are confidential files I can not make the file as public in my storage bucket, so I wanted to use custom signed URL and signed cookies to generate custom signed URL. I am following htafoya answer to generate a custom URL link. While doing so I am confused about the URL part. Which URL is should use? Is it https://<CDN IP Address>/filename.pdf and followed by ?Expires=1600316057&KeyName=demo-key&Signature=jxkWfkEZ_Jl6OKP83Cf13U-gy-e? I am getting an error 403 by using the mentioned URL. Does anybody have an idea of how to generate a custom signed URL using node js?

Update

  1. I can able to fix it by recreating everything.
  2. It is working only for one file. When trying to access the remaining files browser is throwing 403.

Update 1

I found the problem why it is not working:

  1. If any file name contains space, CDN is throwing a 403 permission issue error.

Example: Working: https://<CDN IP Address>/filename.pdf?Expires=1600316057&KeyName=demo-key&Signature=jxkWfkEZ_Jl6OKP83Cf13U-gy-e

Not Working:https://<CDN IP Address>/network architecture.pdf?Expires=1600316057&KeyName=demo-key&Signature=jxkWfkEZ_Jl6OKP83Cf13U-gy-e

Does anyone have any idea on how to resolve this?

  • There should be a `?` after `https:///filename.pdf`, do you have it? There is no Node example in [the docs](https://cloud.google.com/cdn/docs/using-signed-urls#console_1) but the linked code looks good to me. – Emil Gi Sep 17 '20 at 13:50
  • Hi @EmilGi - Thanks for your reply. The complete URL which I am executing along with ? . https:///filename.pdf?Expires=1600316057&KeyName=demo-key&Signature=jxkWfkEZ_Jl6OKP83Cf13U-gy-e still getting`403` error I don't know why – justAnAnotherCoder Sep 18 '20 at 04:03
  • Are you creating a new signed utl for each file you are trying to access? – Emil Gi Sep 18 '20 at 07:18
  • I am trying to access the private file using `Signature`, `Expires ` and `KeyName ` – justAnAnotherCoder Sep 18 '20 at 07:46
  • Is it a permission problem to the `bucket` level? Assuming because of how come I can able to access one file not the other. BTW I have created a bucket permission level as `uniform` . – justAnAnotherCoder Sep 18 '20 at 08:07
  • I think you are misunderstanding it a bit. Signed url is created for a distinct file in the bucket, not the whole bucket, so you need to create a new signed url whenever a new file is requested. – Emil Gi Sep 18 '20 at 10:43
  • Hi @EmilGi - That's correct!! So what I am doing is whenever trying to access a new file from the bucket I generate a newly signed URL by using the `Signing key` and `Signing key Name`. – justAnAnotherCoder Sep 18 '20 at 13:05
  • To clarify you generate new signed url for another file and it returns 403? – Emil Gi Sep 18 '20 at 13:53
  • Yes, @EmilGi. I don't know why I am getting. – justAnAnotherCoder Sep 18 '20 at 13:58

0 Answers0