Firebase 存储 : How to overcome custom claims limits (1000 bytes)

标签 firebase google-cloud-firestore firebase-authentication google-cloud-storage firebase-security

我已经使用 custom_claims 来管理 Firebase 存储上的群组访问权限。但是,它的硬性限制固定为 1000 字节。

在我的应用程序中,用户可以加入 N 个组。今天,我将用户加入的组放入用户的自定义声明中。每个 groupId 都是 Firestore 生成的 key (约 20 字节标准 key )。因此用户将被限制为 50 个组(如果我只计算声明中的 key ..)!

我希望能够根据需要创建尽可能多的关系(在用户和组之间),但由于存储中的规则无法访问 Firestore 数据库,克服此限制的最佳方法是什么?

我考虑过在云函数上创建一个 API 端点,它将返回文件(或直接链接),而不是让客户端(移动设备)直接从存储获取文件。 这是唯一可行的解​​决方案吗?

谢谢

最佳答案

如果您无法在安全规则中表达用于保护内容的逻辑,那么您唯一的选择就是禁止直接客户端访问,并通过您可以控制其逻辑的某个端点路由客户端。这可以是 Cloud Functions 或其他一些后端。

请记住:

  1. Cloud Functions 的响应负载的最大大小为 10MB,因此如果对象可能大于此大小,那么您将需要不同的后端。
  2. 公开对象的链接不会限制该链接与可能无访问权限的其他人共享。您需要一些额外的方法来确保该链接仅适用于请求它的人,也许可以使其仅在一定时间内有效。

关于Firebase 存储 : How to overcome custom claims limits (1000 bytes),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60814333/

相关文章:

javascript - 无法在 Firebase DB 中正确保存

javascript - 在 Firebase 的函数中获取访问 firestore 数据

java - java.lang.NoSuchMethodError : No virtual method fetchProvidersForEmail(Ljava/lang/String;)Lcom/google/android/gms/tasks/Task; mean? 是什么意思

firebase - 将多个身份验证提供程序链接到一个帐户

android - Firebase Remote Config 限速是怎么计算的?

android - 无法解析 : com. firebase :firebase-client-android:2. 3.1

Firebase 功能问题?

firebase - Firestore HTTP 失眠查询 : Stream error in the HTTP/2 framing layer

android - 在 Firestore 中使用对象表示或字符串哪个更可靠

android - 在 Android 应用程序中使用电子邮件 ID 和密码注册