Mateja Petrovic
Mateja Petrovic

Reputation: 4337

Why is Firebase Storage "rules_version = '2'" getting overriden?

I've appended the following line to my storage rules following the docs: rules_version = '2'; Furthermore, my rules are now:

rules_version = '2';
service firebase.storage {
  match /b/{bucket}/o {
    match /{allPaths=**} {
      allow read, write: if request.auth != null;
    }
  }
}

Moreover, I am able to list out the files of a folder using listAll which is an exclusively version 2 feature.

However, each day I come back to my dashboard to find my rules updated to the previous version, being:

service firebase.storage {
  match /b/{bucket}/o {
    match /{allPaths=**} {
      allow read, write: if request.auth != null;
    }
  }
}

How and why does this happen? More importantly, how may I fix the issue?

Upvotes: 2

Views: 3016

Answers (2)

Mateja Petrovic
Mateja Petrovic

Reputation: 4337

With the help from Jonathan from Firebase who was kind enough to remind me of the fact that I am deploying almost on a daily basis I figured out what was going wrong. It turned out that as part of my continuous deployment I was also deploying Firebase storage rules, hence I was indirectly the one overriding my own rules.

Now the obvious and easy solution is to just update the storage.rules file locally.

Upvotes: 2

Doug Stevenson
Doug Stevenson

Reputation: 317562

There are only three ways your rules can change:

  1. Using the Firebase console
  2. Using the Firebase CLI to deploy rules from a local file
  3. Use the Firebase Admin SDK.

If your rules are changing and you are absolutely certain that it's not coming from one of these two methods, contact Firebase support for assistance.

Upvotes: 1

Related Questions