【发布时间】:2020-05-28 23:56:50
【问题描述】:
我一直在 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;
}
}
}
【问题讨论】:
标签: google-cloud-firestore firebase-security