This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(1)
错误消息“FirebaseError : false for 'get'@L5”表示安全规则拒绝安全规则第 5 行的请求。如果您按照如下方式制定了规则,
则第 5 行会出现错误,因为您不允许任何人进行读写访问。
要解决这个问题,您可以将 firestore 规则更改为 :
但这允许将读取和写入操作的规则设置为 true,这意味着您允许任何知道您的项目 ID 的人读取和写入您的数据库,这显然是不好,因为恶意用户可以利用它。确实,您可以在短时间内使用这些设置进行测试,但绝不能在生产环境中使用。
因此,还有另一种选择,您可以将对数据库的访问限制在固定的时间内。今天是 2021 年 3 月 1 日,我们将访问限制为一天:
安全规则中最重要的部分是 Firebase 身份验证,这意味着您只能允许经过身份验证以在数据库中执行操作的用户进行访问。规则应如下所示:
如果您需要一组更细粒度的规则,例如,仅允许 UID 值等于来自身份验证过程的 UID 值的经过身份验证的用户能够写入自己的文档,那么您应该考虑使用以下规则:
功能请求 将此错误消息提交至更精确,如
“FirebaseError: PERMISSION_DENIED 因为安全规则对 'get' @ L5 返回 false”
The error message “FirebaseError : false for ‘get’ @L5” is saying that security rules are denying the request at line 5 of your security rules. If you have curated your rules like below,
then line 5 has the error as you are not allowing read and write access to anyone.
To fix that you can either change your firestore rules to :
but this allows setting your rules to true to both read and write operations, which means that you allow anybody who knows your project ID to read from, and write to your database which is obviously bad, since malicious users can take advantage of it. It’s true that you can use these settings for a small amount of time for testing purposes, but never in a production environment.
So there is another option in which you can limit access to your database to a fixed amount of time. Today is 1.03.2021, we are limiting the access for exactly one day by:
The most important part when it comes to security rules is the Firebase Authentication, meaning that you can allow access only to the users that are authenticated to perform operations in your database. The rules should look like this:
If you need a more granular set of rules, for instance, to allow only the authenticated users, who have the value of the UID equal to the value of UID that comes from to authentication process, to be able to write to their own document, then you should consider using the following rules:
A feature request is filed for this error message to be more precise like
“FirebaseError: PERMISSION_DENIED because security rules returned false for 'get' @ L5”