【发布时间】:2017-11-13 23:41:21
【问题描述】:
我正在努力理解一些 Firestore 安全概念。我想根据request.path 属性设置规则。
我的规则是这样的:
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if request.path[0]=='appUsers';
}
}
}
...然后我使用AngularFire2 添加这样的文档...
this.myAngularFirestore.doc('/appUsers/'+this.auth.auth.currentUser.uid).set({name: this.auth.auth.currentUser.displayName})
.then(()=>console.log('Added user'))
.catch(err=>console.log('Could not add user:', err.message));
我认为这应该很简单 based on the docs 但我得到的只是错误 - Missing or insufficient permissions。
我知道我已正确登录,如果我使用allow read,write: if true; 打开安全性,我知道查询有效,那么我在这里没有得到什么?
request.path[0] 不应该在此处计算为字符串appUsers 从而允许写入数据吗?
任何想法都欣然接受,因为到目前为止我觉得这些规则一起出去并不有趣。
祝大家好运
【问题讨论】:
标签: angular firebase firebase-security angularfire2 google-cloud-firestore