【发布时间】:2017-10-13 17:42:15
【问题描述】:
我正在尝试借助 Firestore 规则建立以下场景。
我怎样才能让用户在没有身份验证的情况下访问“产品”集合,但访问其他经过身份验证的集合?我试过把规则设置如下,但它不起作用。
service cloud.firestore {
match /databases/{database}/documents {
// All should be able to access products collection
match /products {
allow read;
}
// All other collection should only be accessed if user is authenticated.
match /{document=**} {
allow read, write: if request.auth != null;
}
}
}
【问题讨论】:
-
我觉得你需要
match /products/{document=**} -
如果公共收藏是 /shops/{shopId}/products 怎么办
-
那你可能需要
/shops/{shopId}/products/{document=**} -
@MichaelBleigh,它奏效了。谢谢。
标签: firebase firebase-security google-cloud-firestore