【问题标题】:Do I need to explicity state read/write validation rules for each firestore collection?我是否需要为每个 Firestore 集合明确声明读/写验证规则?
【发布时间】:2019-01-14 21:14:36
【问题描述】:

我是否需要明确说明每个集合的读/写(或更细粒度的替代方法 get/list/create/update/delete)验证规则?

或者如果没有提供规则,或者没有说明一些规则,是否默认设置了验证规则?

service cloud.firestore {
  match /databases/{database}/documents {

    function userIsAuthenticated() {
      // ...
    }

    allow read: if true;

    allow create: if
      userIsAuthenticated() &&
      request.resource.data.example is string;

    allow update: if
      userIsAuthenticated() &&
      request.resource.data.example is string;

  }
}

以上不包括delete - 在这种情况下会发生什么?

delete默认为false,还是允许删除数据?

【问题讨论】:

    标签: firebase google-cloud-firestore firebase-security


    【解决方案1】:

    如果您不编写任何规则,所有访问都将被拒绝。您必须编写规则以允许在您指定的条件下访问。

    【讨论】:

      猜你喜欢
      • 2010-09-14
      • 2014-06-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-08
      相关资源
      最近更新 更多