0

I have Firebase Storage that holds hundreds of files secured by Storage rules. The rules check if user requesting the file (URL) has sufficent permissions in Firestore Database.

The problem is that if user tries to access the resource, and is authorized, gets a permanent public link (access token), which can be caught, leaked and accessed by everyone on the whole internet. The link being permanent is unacceptable and represents huge security risk.

The access token (to file) can be revoked in Firebase console by clicking on "Revoke" under "File location" which invalidates the original public link, generating new one on next demand of authorized user. Which is ok.

The question is, is there a way to revoke access tokens on ALL files inside specific bucket/folder at once? Or in a loop, programatically?

1 Answer 1

2

The download token that Firebase stores for each object is stored as metadata on the object itself. All you have to do is write a program to:

  1. Iterate each of the objects in storage using the "list files" API
  2. Remove that token metadata (named firebaseStorageDownloadTokens) from the object

See:

Keep in mind that the download token metadata is not documented by Firebase and is considered an implementation detail, so your code might not work in the future.

3
  • If you now have code, you should post that separately in a new question with an explanation of what you're trying to do and what doesn't work the way you expect. Commented Jul 4 at 20:30
  • Sorry, I managed to figure it out by generating new uuid instead of removing existing. Question: Why revoked URLs still work?
    – t4dohx
    Commented Jul 4 at 20:31
  • No idea. Contact Firebase support. As I said, this is not a documented feature, so you might not have luck getting it to work the way you need. Commented Jul 4 at 20:33

Not the answer you're looking for? Browse other questions tagged or ask your own question.