【问题标题】:Firestore emulator returning Missing or insufficient permissions, worked last weekFirestore 模拟器返回缺少或不足的权限,上周工作
【发布时间】:2021-10-19 05:48:24
【问题描述】:

我在我的项目中进行了一个月的编码工作。在我放暑假之前,一切都很顺利。我有工作身份验证(电子邮件/密码),并且能够向/从 Firestore 模拟器写入和读取数据。

我从暑假回来后身份验证仍然有效,但对 Firestore 模拟器的读/写操作停止了。给我错误“缺少权限或权限不足”。

自 7 月以来几乎没有任何变化。网站正在生产中,突然停止开发。

我错过了今年夏天 Firestore 的重大更新吗?还有其他人遇到类似问题吗?

我已尝试更新 firebase 和 firebase-tools、项目构建,只有身份验证有效,但 firebase 不断抛出错误。我的安全规则适用于生产环境。

编辑:我尝试从 firebase 获取的代码。与以前工作的代码相同。

props.firebase
   .assessments()
   .orderBy('name')
   .get()

编辑:安全规则

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

    // Everything else only available to logged in users
    match /{document=**} {
      allow read, write: if true; // Changed to troubleshoot in development
         // request.auth != null;
    }

    // Only allow users to read, update their own user profile
    match /users/{userId} {
      allow update, write: if request.auth != null 
                         && request.auth.uid == userId;

      allow read: if request.auth != null;
    }

    // Restrict team visibility to team members
    match /teams/{team} {
      allow read, write: if request.auth != null
                         && exists(/databases/$(database)/documents/memberships/$(request.auth.uid+'_'+team) )
    }

    match /tasks/{task} {
      allow read, write: if request.auth != null 
                         && get(/databases/$(database)/documents/users/$(request.auth.uid)).data.teams[request.resource.data.team];
    }

    
  }
}

【问题讨论】:

标签: firebase google-cloud-firestore


【解决方案1】:

我想通了。

我用的是

experimentalForceLongPolling: true

firestore 的配置标志,因为我也在使用 Cypress 进行测试,并且 firebase 和 Cypress 不能很好地混合。

一旦我删除了experimentalForceLongPolling 标志,代码又开始工作了,但我又回到了原点,因为Firebase 身份验证和Cypress 不能很好地混合使用赛普拉斯来测试经过身份验证的页面。

【讨论】:

    猜你喜欢
    • 2019-02-26
    • 2018-04-25
    • 2020-09-01
    • 2020-07-10
    • 2022-01-25
    • 2020-09-08
    • 1970-01-01
    • 2020-11-24
    • 1970-01-01
    相关资源
    最近更新 更多