Firebase存储规则-授予的访问权限不匹配规则

时间:2020-05-01 00:01:21

标签: android firebase firebase-storage firebase-security

这是我的规则:

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

由于某种原因,我可以在以下路径中进行读写:child(Test).child("Image.jpg"),但不应该这样。我应该只能在此路径child(Test).child(Test2).child("Image.jpg")

中读写

Test和Test2都是变量。

我想念什么吗?

1 个答案:

答案 0 :(得分:1)

它正在按预期运行。在安全规则版本2中,递归通配符(allPaths=**)匹配0个或更多路径段。因此,您的规则是匹配country=Testtype=Image.jpg而没有匹配allPaths的内容。

如果只需要两个路径段,则必须完全摆脱allPaths通配符。或者,考虑调用特定的顶级路径组件,而不要通配所有内容。