firebase - Firebase/数据库 - 第 2 版安全规则?
问题描述
我刚刚开始使用 Firebase,并注意到有很多教程/文档指导您将以下内容放入数据库规则中:
{
"rules": {
"$uid": {
".write": "$uid === auth.uid",
".read": "$uid === auth.uid"
}
}
}
但是,似乎有这个代码的新版本,版本 2。我想知道我上面的代码是否已经过时,版本 1(我猜),基本上等同于这个代码:
// Allow read/write access on all documents to any user signed in to the application
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if request.auth.uid != null;
}
}
}
来自 google firebase docs ( https://firebase.google.com/docs/firestore/security/get-started )
谢谢
解决方案
您正在显示来自彼此不直接相关的两种不同产品的规则。
您的第一个示例用于 Firebase 实时数据库。这种基于 JSON 的规则语言多年来没有改变。
您的第二个示例适用于 Firestore。这是一种完全不同的安全规则语言,与 Firebase 实时数据库有点相似,但完全不同。
您所指的规则“版本 2”仅适用于 Firestore。它改变了语言的几个方面的行为,仅此而已。
推荐阅读
- selenium - 如何获取属于特定 TestNG 组的所有测试方法的列表?
- javascript - 在 wordpress add_action 中,javascript 警报仅在 init 中有效,为什么?
- swift - 无法在 UIViewController 上保存 UIImage
- c++ - 我怎样才能打印 BFS 路径本身而不是这个单词阶梯的路径长度?
- c# - 如何在 C#.net 中获取 manifest.json 文件?
- python - 使用现有调用在另一个 AWS lambda 中调用函数
- python - Installing geopandas through conda forces me to remove basemap (windows 8)
- asp.net-core - Asp.net 核心 Kubernetes 作业设置为异常失败状态
- php - 如何结合SQL查询获取总记录和获取分页限制记录
- javascript - '!.' 是什么意思?在javascript中是什么意思?