【问题标题】:firebase storage bucket and Fastly CDN integrationfirebase 存储桶和 Fastly CDN 集成
【发布时间】:2017-02-20 09:56:41
【问题描述】:

为了让我能够快速使用 Firebase 存储,我必须在每个图像和存储桶上添加以下权限:实体:用户,名称:AllUsers,访问权限:读者。有没有办法避免这种乏味且不可扩展的方法,因为它是所有用户上传的媒体?

我的 Firebase 存储安全性如下所示:

service firebase.storage {
  match /b/myapp.appspot.com/o {
match /proUsers/{userId}/{allPaths=**} {
      allow read, write: if request.auth.uid == userId || request.resource.size < 2 * 1024 * 1024 || request.resource.contentType.matches('image/png') || request.resource.contentType.matches('image/jpeg'); 
    }
  }
}

我很快收到的错误是:Anonymous users does not have storage.objects.list access to bucket,如果我尝试直接访问图像,我会收到错误:Anonymous users does not have storage.objects.get access to object

我在哪里允许匿名用户拥有阅读能力?我假设设置允许读取正是这样做的。

【问题讨论】:

    标签: firebase firebase-security firebase-storage fastly


    【解决方案1】:

    要允许匿名用户从您的数据库中读取(但不能写入),您可以将规则更改为:

    service firebase.storage {
      match /b/myapp.appspot.com/o {
    match /proUsers/{userId}/{allPaths=**} {
          allow write: if request.auth.uid == userId || request.resource.size < 2 * 1024 * 1024 || request.resource.contentType.matches('image/png') || request.resource.contentType.matches('image/jpeg');
          allow read;
        }
      }
    }
    

    【讨论】:

      猜你喜欢
      • 2018-10-04
      • 2023-02-01
      • 1970-01-01
      • 2016-09-16
      • 1970-01-01
      • 1970-01-01
      • 2016-05-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多