【问题标题】:making a folder public in Firebase Storage在 Firebase 存储中公开文件夹
【发布时间】:2019-09-07 07:04:36
【问题描述】:

我需要在 Firebase 存储中设置一个只有读取权限的公共文件夹,我的安全规则是

service firebase.storage {
  match /b/{bucket}/o {
    match /{allPaths=**} {
      allow read, write:if request.auth.uid != null;
    }
    match /{platos=**} {
      allow read;
    }
  }
}

该文件夹称为 platos,我不确定这些规则是否受到保护,其他文件夹必须仅对登录用户具有保护

【问题讨论】:

  • 取决于你叫什么secured。您允许登录到您的 firebase 项目的任何人读取和写入所有文件路径。

标签: firebase firebase-storage firebase-security


【解决方案1】:

你可以删除验证码request.auth.uid != null,只授予读取权限。

service firebase.storage {
  match /b/{bucket}/o {
    match /{allPaths=**} {
      allow read;
    }
  }
}

【讨论】:

    【解决方案2】:

    第一条规则应该与您的文件夹有关,否则将应用拒绝读取的第一条规则:

    rules_version = '2';
    service firebase.storage {
      match /b/{bucket}/o {
        match /platos/{allPaths=**} {
            allow read;
            allow write: if request.auth != null;
        }
        match /{allPaths=**} {
          allow read, write: if request.auth != null;
        }
      }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-09-08
      • 1970-01-01
      • 2016-10-06
      • 2018-01-28
      • 2019-03-31
      • 2022-01-24
      • 2023-03-14
      • 1970-01-01
      相关资源
      最近更新 更多