Javascript 即使使用公共数据库,权限也缺失或不足
我有一个盖茨比/firebase项目运作良好,在那里呆了一个星期,没有做任何改变。现在我只是回来更新一些东西,我有以下错误:Javascript 即使使用公共数据库,权限也缺失或不足,javascript,firebase,webpack,google-cloud-firestore,gatsby,Javascript,Firebase,Webpack,Google Cloud Firestore,Gatsby,我有一个盖茨比/firebase项目运作良好,在那里呆了一个星期,没有做任何改变。现在我只是回来更新一些东西,我有以下错误: index.js:2177 FirebaseError: Missing or insufficient permissions. at new FirestoreError (http://localhost:8000/commons.js:4331:28) at JsonProtoSerializer../node_modules/@firebase/
index.js:2177 FirebaseError: Missing or insufficient permissions.
at new FirestoreError (http://localhost:8000/commons.js:4331:28)
at JsonProtoSerializer../node_modules/@firebase/firestore/dist/index.esm.js.JsonProtoSerializer.fromRpcStatus (http://localhost:8000/commons.js:19005:16)
at JsonProtoSerializer../node_modules/@firebase/firestore/dist/index.esm.js.JsonProtoSerializer.fromWatchChange (http://localhost:8000/commons.js:19502:44)
at PersistentListenStream../node_modules/@firebase/firestore/dist/index.esm.js.PersistentListenStream.onMessage (http://localhost:8000/commons.js:15457:43)
at http://localhost:8000/commons.js:15386:30
at http://localhost:8000/commons.js:15426:28
at http://localhost:8000/commons.js:5669:20
我想我的firebase规则可能有一些bug,然后我将其更改为public:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write;
}
}
}
而我仍然得到同样的错误。我试过:
-更新npm依赖项
-清除应用程序存储
-盖茨比清洁酒店
这些都不管用。firebase身份验证工作正常。猜猜问题出在哪里
编辑:
我用传奇故事来阅读代码:
firebase.js
...
export const authRef = function() {
return firebase.auth();
}
export const firestoreRef = function() {
return firebase.firestore();
}
...
我发现了这个问题。我团队的一名成员最终更改了google cloud的IAM配置,禁用了在firestore中应用firebase规则的服务帐户
在Firebase支持团队的帮助下,我发现了它。因此,我刚刚检查了更改的历史记录,并取消了对数据库访问权限的破坏请在您的问题中添加实际读取/写入的代码。没有这些,很难说你的规则为什么会失败。当然@FrankvanPuffelen。我刚才加了一句:嗯。。。。我没有马上看出有什么不对劲。你能试一下允许读写吗:如果是真的;?我自己从不依赖于一个空的状态,我想知道这是否已经改变了。如果不是这样的话,我希望其他人能看到问题所在。我只是按照你说的更改了规则,但没有起作用:。我开始认为这可能是firebase服务器的一个bug。我请求他们的支持,看看这是我的代码中的问题还是他们服务器中的错误。它在其他计算机或匿名标签中不起作用。当然,这可能是一个bug,但我希望更多的人报告它。任何方式:支持团队都是一个很好的帮助方式,因为如果需要,他们可以查看您的项目,所以让我们看看我们还能做些什么。您能否尝试在Firebase控制台的模拟器中重现该问题?
import {firestoreRef, authRef} from './firebase';
function* loadProjectsData() {
try {
const firestore = firestoreRef();
const userId = authRef().currentUser.uid;
const query =
firestoreRef()
.collection('projects')
const snap = yield call(
[
query,
query.get
]
);
} catch(error) {
console.error(error);
}
}