google-cloud-firestore - 30 天后 Firestore 中的安全规则
问题描述
我一直在 Firestore 中开展一个项目,当我开始时,我选择了 Firestore 的测试模式,显然可以为您提供 30 天的“试用”,之后我必须更改安全内容,但我已经编写了所有收集数据和我的 Firestore 中已经有其他功能了。如果我在安全部分添加一行代码,我会得到这 30 天的“试用”吗?
我去更改了安全规则,所以我不会丢失我的数据库,正常的规则是:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
// This rule allows anyone on the internet to view, edit, and delete
// all data in your Firestore database. It is useful for getting
// started, but it is configured to expire after 30 days because it
// leaves your app open to attackers. At that time, all client
// requests to your Firestore database will be denied.
//
// Make sure to write security rules for your app before that time, or else
// your app will lose access to your Firestore database
match /{document=**} {
allow read, write: if request.time < timestamp.date(2020, 6, 2);
}
}
}
如果我将此规则添加到此,我不会丢失我拥有的 Firestore 东西吗?
match /users/{uid} {
allow read;
allow write: if request.auth.uid == uid;
}
这是最终代码的样子:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
// This rule allows anyone on the internet to view, edit, and delete
// all data in your Firestore database. It is useful for getting
// started, but it is configured to expire after 30 days because it
// leaves your app open to attackers. At that time, all client
// requests to your Firestore database will be denied.
//
// Make sure to write security rules for your app before that time, or else
// your app will lose access to your Firestore database
match /{document=**} {
allow read, write: if request.time < timestamp.date(2020, 6, 2);
}
match /users/{uid} {
allow read;
allow write: if request.auth.uid == uid;
}
}
}
解决方案
如果您的目标是延长您的“试用期”(实际上并非如此 - 它提醒您确实应该制定适当的规则),那么您所要做的就是延长编码到您的规则中的日期'已经给了。
如果您没有完全删除该原始规则并提出适当的规则,您将继续收到来自 Firebase 的电子邮件,提醒您您的规则存在严重的安全问题。如果你只是给它添加规则,那不会改善这种情况,因为规则实际上是让世界完全可以访问其他所有东西,无论如何。 您最终将需要删除规则并将其替换为准确描述系统安全要求的内容。
推荐阅读
- python-3.x - 将百分比变化映射到 Pandas 或 Numpy 中的字符串描述
- perforce - 强制覆盖版本的历史记录?
- ruby-on-rails - 尝试在 Mac 上本地运行 Rails + React 应用程序时,如何修复“端口已在使用”错误?
- flutter - 如何在 DateTimeField Flutter 中删除确定按钮并取消
- nginx - htpasswd 文件和 NGINX
- awk - 如何使用 awk/grep 从文件中搜索存储在变量中的值
- json - 如何处理多种日期格式?火花 - 斯卡拉
- c - C语言相同的代码导致main和function不同
- python - Django:如何以 Django 方式优化和减少重复代码?
- firebase - 地图或数组中的最大字段深度?使用限制问题