首页 > 解决方案 > 如何为不同的集合设置不同的规则

问题描述

我希望我的应用程序仅在身份验证之前从 firebase 读取语言集合数据,并且仅在用户通过身份验证时从用户集合中读取数据。在此处输入图像描述

我的规则 在此处输入图像描述

标签: google-cloud-firestorefirebase-authenticationfirebase-security

解决方案


据我所知,您要求:

service cloud.firestore {
  match /databases/{database}/documents {
    match /Language/{document} {
      allow read: if true;
    }
    match /Users/{document} {
      allow read: if request.auth != null;
    }
  }
}

有了上述任何用户(无论他们的身份验证状态)都可以读取Language集合,但只有经过身份验证的用户才能读取Users集合。


推荐阅读