【发布时间】:2019-01-29 22:47:10
【问题描述】:
我正在为病历应用程序开发 Firestore 安全规则。我希望将员工和患者存储在不同的集合中,以确保符合 HIPAA(例如人力资源或呼叫中心工作人员不应该看到临床记录)。患者属于一个组,该组确定他们可以使用哪些产品。患者不应看到其他群体的产品。员工需要有权查看任何产品。
数据如下所示:
patient : {
groupId: 1
}
product : {
groupId: 1
}
staff: {
canReadProducts: true
}
此规则允许患者阅读产品文档:
match /products/{productId} {
allow read: if get(.../patients/$(request.auth.uid))
.data.groupId == resource.data.groupId
}
此规则允许员工阅读产品文档:
match /products/{productId} {
allow read: if get(.../staff/$(request.auth.uid))
.data.canReadProducts == true;
}
这条规则不起作用:
match /products/{productId} {
allow read: if get(.../patients/$(request.auth.uid))
.data.groupId == resource.data.groupId
|| get(.../staff/$(request.auth.uid))
.data.canReadProducts == true;
}
为了这个问题,这些都被简化了,我正在测试用户是否经过身份验证,并且还使用 .exists() 调用来检查文档是否存在。读取文档路径中的“...”来读取“/database/$(databases)/documents”。
我的问题是:如何让多个 .get() 调用在这个场景中工作?
【问题讨论】:
-
快速澄清我要问的内容:除了每个规则的资源外,我如何调用多个文档。这似乎是问题所在,我正在针对产品文档(资源)、患者文档和员工文档进行测试。
标签: firebase google-cloud-firestore firebase-security