Firebase Storage Rules - access granted doesn't match rules

烈酒焚心 提交于 2020-05-15 08:02:08

问题


Here is my rules :

rules_version = '2';
service firebase.storage {
  match /b/{bucket}/o {
    match /{country}/{type}/{allPaths=**} {
      allow read, write;
    }
  }
}

For some reason I can write and read in this path : child(Test).child("Image.jpg") but it shouldn't be. I should only be able to write and read in this path child(Test).child(Test2).child("Image.jpg")

Test and Test2 are both variables.

Am I missing something?


回答1:


It's working as I would expect. In security rules version 2, recursive wildcards (allPaths=**) match 0 or more path segments. So, your rule is matching country=Test and type=Image.jpg with nothing matched for allPaths.

If you want only two path segments, you'll have to get rid of the allPaths wildcard entirely. Or, consider calling out specific top-level path components instead of wildcarding everything.



来源:https://stackoverflow.com/questions/61534818/firebase-storage-rules-access-granted-doesnt-match-rules

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!