相关疑难解决方法(0)

如何仅允许公开访问firestore文档的特定字段

假设我在firestore数据库中有这个结构:

collection[
  document: {
    x: 'x',
    y: 'y'
  }
]
Run Code Online (Sandbox Code Playgroud)

我有这个firebase规则:

service cloud.firestore {
  match /databases/{database}/documents {
    match /collection/{document} {
      allow read: if true;
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

但是这个规则暴露了document上面的整体collection,我想要做的只是暴露x场,是否可能?谢谢

firebase firebase-realtime-database google-cloud-firestore

6
推荐指数
1
解决办法
1830
查看次数

Cloud Firestore安全规则 - 文档中的单个受保护字段

我想suspendedProfile在一个user文档中调用一个只读属性,其中所有其他属性都具有当前登录用户的读/写访问权限.有没有办法用简单的安全规则来做到这一点?

我想到了两个解决方案:

  1. 禁止写入修改属性,如 allow write: if request.resource.data.suspendedProfile == null;
  2. 一个/secure与集合allow read;内部user文件

我认为第一个选项是更好的所有与用户相关的属性都在一个单独的文件中,但我很想听听你的想法.有没有其他更简单的方法来实现这一目标?

firebase firebase-security google-cloud-firestore

5
推荐指数
1
解决办法
1253
查看次数