首页 > 解决方案 > 增加规则的 Firebase 时间戳日期

问题描述

嗨,无论如何,有没有实际增加这条规则的时间戳?我正在使用云火库

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {

    // This rule allows anyone on the internet to view, edit, and delete
    // all data in your Firestore database. It is useful for getting
    // started, but it is configured to expire after 30 days because it
    // leaves your app open to attackers. At that time, all client
    // requests to your Firestore database will be denied.
    //
    // Make sure to write security rules for your app before that time, or else
    // your app will lose access to your Firestore database
    match /{document=**} {
      allow read, write: if request.time < timestamp.date(2020, 1, 16);
    }
  }
}

它说那里是 2020 年 1 月 16 日,如果低于这个数字,它将允许从我的数据库中读取和写入数据。但它已经是 1 月 17 日在菲律宾。

我尝试将 timestamp.date 从更改为2020, 1, 162020, 3, 15但我的 Flutter 应用程序仍然没有从数据库中读取任何内容。

我期望的是在我增加时间戳日期之后,它将允许我的应用程序从数据库中读取直到给定时间。现在,即使我增加了它,该应用程序也不会从数据库中读取任何内容

这是我的代码:

  @override
  Widget build(BuildContext context) {

    width = MediaQuery.of(context).size.width;

    return SafeArea(
        child: Scaffold(
          backgroundColor: Color(0xFF0d192a),
        appBar: CustomAppBar(height: 90),
        drawer: DrawerNiVlad(),
        body: ListView(
          children: <Widget>[


          ArlTitleText('EXPLORE V!'),
          sb5,
          HeaderCarousel(),
          sb30,


          ArlTitleText('DISCOUNT SECTION'),
          sb5,
          // DiscountWidget(),
          sb30,

          ArlTitleText('DUMMY SECTION'),
          ArlBodyText('Lorem ipsum yes yes show boom tarat tarat yea boy Lorem ipsum yes yes show boom tarat tarat yea boy Lorem ipsum yes yes show boom tarat tarat yea boy'),
          sb30,

        ],
        ),
      ),
    );
  }

部分的内容:折扣和虚拟部分来自数据库,它不会出现,因为它在我的 vscode 中显示此错误:

在此处输入图像描述

以及来自 firebase 的电子邮件说:

You chose to start developing in Test Mode, which leaves your Cloud Firestore database completely open to the Internet. Because your app is vulnerable to attackers, your Firestore security rules were configured to stop allowing requests after the first 30 days.
In 0 day(s), all client requests to your Firestore database will be denied. Before that time, please write strong security rules that allow your app to function while appropriately protecting your data. Analysis is run daily; if you've modified your rules in the last 24 hours those changes may not be accounted for.

标签: firebasefluttergoogle-cloud-firestorefirebase-security

解决方案


您需要设置身份验证来解决此问题。如果您仍然希望拥有基于时间戳的访问权限,则仍需要使用身份验证。我建议阅读本指南以获取有关警告的更多详细信息。


推荐阅读