Firestore Firebase中的规则

发布于 2025-01-23 18:10:28 字数 747 浏览 0 评论 0原文

我正在为Firestore数据库设置规则,但我无法理解恶意用户的含义。如果我有道路: /innction_user_item/prova/item/a23w4 ....其中a23w4 ..是uid。对于此路径,我设置以下规则:

match /junction_user_item/{multiSegment=**}/{userId}{
    allow read: if request.auth != null
    allow write: if request.auth != null
}

此路径的每个文档都包含“喜欢”的值(每次登录用户显示该文档时,如果您喜欢图片: 喜欢:firebase.firestore.fieldvalue.increment(1)

这个想法是,路径`/innction_user_item/prova/prova/items/'有一系列照片,任何人都可以通过编辑文档来喜欢它。

现在,登录的恶意用户可以做什么?他可以使用那条路并提高“喜欢”财产的任何文件?我不能说:

allow read, write: if request.auth != null && request.auth.uid == userId

因为该路径下的文档必须可供所有人访问。

另外,如何确保没有人可以编辑/删除路径?

/junction_user_item/PROVA 

I am setting the rules for my firestore database but I can't understand the meaning of malicious user . If I have the path:
/junction_user_item/PROVA/items/A23W4.... where A23W4.. is the uid . For this path I set the following rule:

match /junction_user_item/{multiSegment=**}/{userId}{
    allow read: if request.auth != null
    allow write: if request.auth != null
}

Each document of this path contains the value 'likes' (each time the document is displayed by any logged-in user, the value can be incremented by 1 if you like the picture:
likes:firebase.firestore.FieldValue.increment(1)

The idea is that under the path `/junction_user_item/PROVA/items/' there is a collection of photos and anyone can like it by editing the document.

Now, what can a malicious user who has logged in do? Can he use that path and increase the 'likes' property by as much as he wants of any document ? I can't put the rule :

allow read, write: if request.auth != null && request.auth.uid == userId

because the documents under that path must be accessible to everyone.

Also how to make sure no one can edit/delete the path?

/junction_user_item/PROVA 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文