所有Firestore
因此,如果我的应用程序允许用户编辑其配置文件文档的某些字段,那么我如何使用规则锁定仅应用程序才能编辑的其他字段?
还是我误解了为什么有必要进行弗雷斯特尔规则,如果是这样,您能解释一下吗?谢谢
All of the firestore security documents seem to have an assumption that users are malicious enough to hack their own apps and start using that exploited app to take advantage of weak database rules.
Therefore, if my app allows a user to edit certain fields of their profile document, how can I use the rules to lockdown the other fields that only the application should be able to edit?
Or have I misunderstood why firestore rules are necessary, if so, could you please explain? Thank you
发布评论
评论(2)
您的问题实际上可以应用于您希望最终用户能够仅修改文档字段的任何firestore文档。
有一个特定的
并显示以下示例:
允许用户“更新有关餐厅的信息,但不更改其平均得分或评论数”。
You question can actually apply to any Firestore document for which you want an end-user to be able to modify only a subset of the document's fields.
There is a specific section in the documentation, which is titled "Preventing some fields from being changed" and which indicates that:
and which shows the following example:
which allows users "to update information about a restaurant but not change their average score or number of reviews."
[按照下面的评论进行编辑]
如果您查看文档:
他们指定以下内容:
反向逻辑在:
[Editing following the comment below]
If you look at the documentation:
https://firebase.google.com/docs/firestore/security/rules-fields#preventing_some_fields_from_being_changed
they specify the following:
reverse logic is in:
https://firebase.google.com/docs/firestore/security/rules-fields#allowing_only_certain_fields_to_be_changed