如何使用 Firestore 实现用户组类型的安全性(例如共享待办事项列表)?

how to implement user group type security with Firestore (e.g. a shared todo list)?

在 Firestore 中为移动应用程序实施安全组的最佳实践方法是什么(在本例中,react-native 有效地使用了 "Web" 接口)。举个更具体的例子:

我的问题是你如何总体上实施上述内容,但涵盖了

等方面

总体而言,热衷于了解让用户安全地(在具有 firestore "web" sdk 的移动应用程序上,即 react-native wrapper)与其他人共享他的数据(例如待办事项列表)的最低摩擦方法 he/she 特别是 selects/approves 不知何故。

为了后代,这个问题已经在 google-cloud-firestore-discuss group: https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!msg/google-cloud-firestore-discuss/KEs4is11LXc/xs2zIvQmCQAJ

上得到了回答

TL;DR:

service cloud.firestore {
  match /databases/{database}/documents {
    match /lists/{listId} {
      // step 1
      allow create: if request.resource.data.owner == request.auth.uid;
      // step 3
      allow get: if exists(/databases/$(database)/documents/lists/$(listId)/users/$(request.auth.uid));
      match /users/{userId} {
        // step 2
        allow create: if request.auth.uid == get(/databases/$(database)/documents/lists/$(listId)).data.owner;
      }
    }
  }
}