How to track down source of “Missing or insufficient permissions” in Firestore?

眉间皱痕 提交于 2019-12-08 07:23:06

问题


NOTE: This question is not about how to resolve any particular "Missing or insufficient permissions" Firestore error. This question is about tracking down the source of the error. Every other question on S.O. that I've been able to find that references this error in Firestore is asking a different question, so please read through the entire question and check creation dates on any other questions you find before you try to mark this as a duplicate.

tl;dr: Is there a good way to track down either the location in code that triggers this error or the specific security rule that is being violated?

When the Firebase library throws this error it doesn't provide any information about where in the code this error is being throw or which security rule is being violated (which is probably a good thing, since in the wild, providing this information could make it easier for a hacker to do something nefarious). However, in development, it makes things difficult to debug. If I'm working on a particular query, it's usually not a problem, because when I make a change and see this error, I know the code I was just working on is causing the error. But there are other circumstances where the source is less obvious.


回答1:


Learn how to use the Firebase security rules emulator. It will show you what's happening during rule evaluation. Other than this, there are currently no diagnostics to help you understand what's happening with security rules deployed to your project when invoked from client code.

https://firebase.google.com/docs/firestore/security/test-rules-emulator



来源:https://stackoverflow.com/questions/57938882/how-to-track-down-source-of-missing-or-insufficient-permissions-in-firestore

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!