应用程序的Xamarin Firebase身份验证

时间:2020-06-26 09:25:22

标签: firebase xamarin

在学习过程中,我创建了一个简单的(Android)游戏,其中用户的结果存储在Firebase数据库中。出于开发目的,我将Firebase规则设置为可以不受限制地进行读写。现在,我想使用规则,其中只有我的应用程序可以在数据库中读/写。 我该怎么做?浏览后,我发现样本中的用户具有自己的用户名/密码。我没有那种申请。我只希望只有我的应用可以访问数据库。

1 个答案:

答案 0 :(得分:0)

下面是一个规则示例,该规则为每个经过身份验证的用户提供位于/users/$user_id的个人节点,其中$user_id是通过Authentication获得的用户的ID。对于任何具有用户专用数据的应用程序,这是一种常见情况。

// These rules grant access to a node matching the authenticated
// user's ID from the Firebase auth token
{
  "rules": {
    "users": {
      "$uid": {
        ".read": "$uid === auth.uid",
        ".write": "$uid === auth.uid"
      }
    }
  }
}

更多信息可以在这里参考:https://firebase.google.com/docs/database/security/quickstart#user