Firebase:身份验证中的用户信息是否有安全规则?

问题描述 投票:-2回答:1

身份验证中的firebase用户信息是否具有保护安全规则,就像我们在firestore中一样?

目前,我们使用以下安全规则保护firestore集合。

service cloud.firestore {
  match /databases/{database}/documents {

    match /employees/{document=**} {
      allow read: if request.auth.token.admin == true || request.auth.uid == user
      allow write: if false;
    }
  }
}

上述集合的写操作由firebase管理员在firebase函数中完成,因此我阻止了来自客户端的所有写访问。

我通过firebase管理sdk在firebase函数中访问Authentication Users表。我想知道是否有安全规则来启用和禁用客户端的访问。

谢谢。

firebase firebase-authentication firebase-security-rules
1个回答
0
投票

通过Firebase Admin SDK(或任何其他服务器SDK)对Firestore的所有访问都完全绕过安全规则。目前无法从服务器SDK模拟用户访问。您必须在后端代码中复制安全规则的逻辑。

如果您希望有适用于后端代码的安全规则,您可以随时使用file a feature request,但我认为它不会很快发生。有关管理SDK和安全规则之间关系的更多信息,请访问Read this blog

© www.soinside.com 2019 - 2024. All rights reserved.