如何使用 Firestore 实现用户组类型的安全性(例如共享待办事项列表)?
how to implement user group type security with Firestore (e.g. a shared todo list)?
在 Firestore 中为移动应用程序实施安全组的最佳实践方法是什么(在本例中,react-native 有效地使用了 "Web" 接口)。举个更具体的例子:
- 使用能够"share"存储在 Firestore 中的数据(例如待办事项列表)的移动应用的用户[使用 "Web" 界面构建]
- 旨在采用非常低的摩擦方法。理想情况下,主要用户使用 "Anonymous" 身份验证方法
使用该应用程序
- 然后用户想"share"与他人安全地"share"数据(例如待办事项列表)
我的问题是你如何总体上实施上述内容,但涵盖了
等方面
- Q1 - 在用户体验方面,您要求/让用户在这里做什么?将其构建到应用程序代码中?
- 问题 2 - 您如何构建 Firestore 数据库来处理这个问题?即结构会是什么样子——也许所有数据都在主用户 UID
之下
- Q3 - 您如何构建 Firestore 规则来保护它?例如你如何在这里进行 "user-in-group" 类型检查?例如?
- Q4 - 应用程序代码看起来像什么:
- 在主用户点击 "share"
时创建用户安全组
- 添加用户到群组?
- 正在访问数据?
总体而言,热衷于了解让用户安全地(在具有 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;
}
}
}
}
在 Firestore 中为移动应用程序实施安全组的最佳实践方法是什么(在本例中,react-native 有效地使用了 "Web" 接口)。举个更具体的例子:
- 使用能够"share"存储在 Firestore 中的数据(例如待办事项列表)的移动应用的用户[使用 "Web" 界面构建]
- 旨在采用非常低的摩擦方法。理想情况下,主要用户使用 "Anonymous" 身份验证方法 使用该应用程序
- 然后用户想"share"与他人安全地"share"数据(例如待办事项列表)
我的问题是你如何总体上实施上述内容,但涵盖了
等方面- Q1 - 在用户体验方面,您要求/让用户在这里做什么?将其构建到应用程序代码中?
- 问题 2 - 您如何构建 Firestore 数据库来处理这个问题?即结构会是什么样子——也许所有数据都在主用户 UID 之下
- Q3 - 您如何构建 Firestore 规则来保护它?例如你如何在这里进行 "user-in-group" 类型检查?例如?
- Q4 - 应用程序代码看起来像什么:
- 在主用户点击 "share" 时创建用户安全组
- 添加用户到群组?
- 正在访问数据?
总体而言,热衷于了解让用户安全地(在具有 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;
}
}
}
}