Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase storage: files always accessible via URL?

I am building a small web app using Firebase.

There is the steps :

The User connect (Firebase authentication)

The user upload an image (Firebase storage)

The user can download or see his images

<img [src]="imageFromFirebase">

The url given by firebase looks like :

https://firebasestorage.googleapis.com/v0/b/<Your API>/o/userData_YOQioOsgzUP0B0fTAa6BVK5KOxo2%2Fimages%2F-L-w7THGfT6qmX9UhLsK3.png?alt=media&token=61f6edf9-188e-4177-9ee2-34635ebc5a4a

With this URL, I can display the image on the browser only if the user is conneted.

The real problem is that I copied this URL and past it in another web browser (without being authenticated)

And SURPRISE !! this image is displayed !

I don't understand why the image is displayed ?

It is normal ?

Thank you !

like image 650
NoteStylet Avatar asked Dec 23 '22 11:12

NoteStylet


1 Answers

When you generate a download URL for a file in Cloud Storage for Firebase, anyone who has the URL will be able to download its contents. This is by design. The URL is "unguessable", so only people who actually have the URL will be able to see the content.

If you don't want people to see that file, then don't share the URL. If the URL is accidentally shared to others who shouldn't have access, you can revoke the token that allows everyone to see the content.

like image 109
Doug Stevenson Avatar answered Dec 28 '22 08:12

Doug Stevenson