How to Create Signed URL in GCP

Create Singed URL:    

Create a Signed URL Using gsutil:-


How to Create Signed URL in GCP


— A Singed URL is a URL that provides limited permission and time to make a Request.


— Singed URLs contain authentication information in their Query String, allowing users without Credentials to perform specific actions on a source.



Key Parameters in Sign URL:-


  1. X-Goog-Algorithm: - The Algorithm used to Sign the URL.


  1. X-Goog-Credentials: - Information about the Credentials used to Create the Signed URL.


  1. X-Goog-Date: - The date and time the Singed URL became usable, YYYYMMDD ’T’ HHMMSS ‘Z’ 


  1. X-Goog-Expires:- The length of time the Signed URL remained Valid, measured in sec. In our case we’ll take 60 Sec. Max. Duration is 60, 4800 Sec i.e 7days.


  1. X-Goog-SignedHeader: - The Header that had to be included as part of any request that used the Signed URL.


  1. X-Goog-Signature: - The authentication String that allowed request using this Signed URL to Access Resources.





Labs:-


Go to Cloud Storage:


— Create a Bucket gcs-datahouse

— Upload a file like an image.

 

— Now Go to APIs & Services

— Credentials 

— Create Credentials                   — Service account         — If not exist then create it otherwise leave it.


— Click on Service Accounts

— KEYS

— ADD KEY

— Create new key

— Selecte JSON

— Create


Now Go to GCP terminal:-


$ sudo rm -rf $HOME

$ restart

$ ls


— Click on upload via GCP console on terminal itself. 

— Upload key which you created earlier.


$ sudo su

$ ls

$ pip install pyopenssl -y


$ gsutil signurl -d 60s key.JSON gs://gcs-datahouse/image.JPG


— Authorize

— We’ll get an url using this URL anyone can see the data for given timeline.


— Delete the key

— Delete files from bucket

— Delete Bucket






🙏 thanks





























Previous
Next Post »