【发布时间】:2019-07-29 11:22:34
【问题描述】:
在 Firestore 访问规则中使用 allow list; 和 allow read; 有什么区别?更具体地说,如果我只允许 list 而不是 read 限额,我的数据会得到什么额外保护?
在我看来,read 和 list 提供了相同的安全性,他唯一的区别是 list 使得合法访问单个对象变得更加麻烦。毕竟,一个坏演员可以简单地列出对象,然后阅读它们的全部内容。如果他知道对象的 ID,他可以简单地将其作为搜索词包含在内。
// The scopes collection is restricted to only allow 'list' requests.
// The scopes collection contains a 'postPhoto' document
// The following request will fail with an insufficient permission error, as expected
await db
.collection(`/auth/${client}/scopes`)
.doc('postPhoto')
.get()
.then(doc => console.log(doc.id, doc.data()))
.catch(e => console.error(e))
// But this request will succeed, and it is in effect the same as the previous
await db
.collection(`/auth/${client}/scopes`)
.where(firebase.firestore.FieldPath.documentId(), '==', 'postPhoto')
.get()
.then(col => col.forEach(doc => console.log(doc.id, doc.data())))
.catch(e => console.error(e))
我原以为list 访问权限只允许您查看文档的存在,而不能查看其内容。但既然list 显然也允许您访问底层文档数据,为什么不直接使用read?
【问题讨论】:
标签: firebase google-cloud-firestore firebase-security