保护Firestore中的特定“文档"字段 [英] Securing specific Document fields in Firestore

查看:62
本文介绍了保护Firestore中的特定“文档"字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个简单的系统,该系统允许用户使用他们提供的信息来创建一个帐户.现在,我将所有数据存储在一个集合users中,该集合具有一些表示用户的文档.
我想将用户的一些敏感数据(例如电子邮件地址和电话号码)保密.在Firebase数据库中,我将创建以下内容:

I'm trying to create a simple system that allows users to create an account with info that they provided. Right now, I store all the data in a Collection users which has some Documents that represents users.
I'd like to keep some sensitive data of the user, such as the email address and phone number, private. In Firebase Database I would've created something like this:

  users: {
    uid: {
      public_info:...
      private_info:...
    }
  }

在这里保护数据非常简单.我只是为private_infopublic_info写不同的规则集.
这样在Firestore中如何实现?

Protecting the data in here is pretty straight forward. I would simply write different rule sets for the private_info and public_info.
How would something like this be achieved in Firestore?

推荐答案

为用户的公共和私有数据使用不同的顶级集合,并适当地设置其规则.

Use different top-level collections for user public and private data, and set their rules appropriately.

这篇关于保护Firestore中的特定“文档"字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆