【问题标题】:Do Firestore subdocuments inherit any permissions from parent documents?Firestore 子文档是否继承父文档的任何权限?
【发布时间】:2021-05-29 23:25:42
【问题描述】:

例如我有一个文档parentDoc,其中包含一个集合subDocs 和一个childDoc,它是该subDocs 集合的一部分。如果用户没有阅读parentDoc的权限,他们是否也无法阅读childDoc

【问题讨论】:

    标签: firebase google-cloud-firestore firebase-security


    【解决方案1】:

    如果“权限”是指“安全规则”,那是正确的。安全规则的默认设置是用户无权访问。

    【讨论】:

      【解决方案2】:

      是和否,这在很大程度上取决于您的规则本身以及您是否使用通配符。根据经验,默认情况下所有请求都被拒绝,并且必须匹配有效的安全规则才能从该位置读取,然后这些规则从上到下级联并且不能覆盖以前的目录。

      例如:

      service cloud.firestore {
        match /databases/{database}/documents {
          match /myDocument/ {
            // this targets a document named "myDocument"
            // this WILL be in effect as no rule above applies to this location
            match /posts/{moreDocuments} {
              // this targets all documents under a collection called "posts"
              // this WILL override the above rule on documents that follow this path
              // as no wild card above exists to conflict with this location
            }
          }
          match /{document=**} {
            // this uses a wild card that applies to ALL children documents as a default
            // this will override any following Security Rules
          }
          match /otherDocument/ {
            // this targets a document named "otherDocument
            // this will NOT be in effect as the rule above applies to this location
          }
        }
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2021-07-17
        • 1970-01-01
        • 1970-01-01
        • 2019-10-06
        • 2018-04-29
        • 2018-08-08
        • 2016-06-17
        相关资源
        最近更新 更多