Cha*_*har 1 firebase firebase-security google-cloud-firestore
我正在尝试借助 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;
}
}
}
Run Code Online (Sandbox Code Playgroud)
像这样的事情会起作用:
service cloud.firestore {
match /databases/{database}/documents {
// All should be able to access products collection
match /products/{allProducts=**} {
allow read;
}
// All other collection should only be accessed if user is authenticated.
match /{notProducts}/{allNotProducts=**} {
allow read: if notProducts != "products"
&& request.auth != null;
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1533 次 |
| 最近记录: |