【问题标题】:Security Rules in Firestore after 30 days30 天后 Firestore 中的安全规则
【发布时间】: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


    【解决方案1】:

    如果您的目标是延长您的“试用期”(实际上并非如此 - 它提醒您确实应该制定适当的规则),那么您所要做的就是延长编码到给你的规则。

    如果您不完全删除该原始规则并提出适当的规则,您将继续收到来自 Firebase 的电子邮件,提醒您您的规则存在严重的安全问题。如果你只是给它添加规则,那不会改善这种情况,因为规则实际上是让世界完全可以访问其他所有东西,无论如何。 您最终需要删除该规则并将其替换为准确描述系统安全要求的内容。

    【讨论】:

      猜你喜欢
      • 2018-10-19
      • 2019-07-05
      • 2020-06-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-21
      • 1970-01-01
      相关资源
      最近更新 更多