Firestore错误 - >错误:权限丢失或不足

时间:2017-11-12 12:17:48

标签: javascript google-cloud-firestore

我偶尔会在我的应用程序中遇到此错误,该应用程序在客户端前端(JS Firebase / Firestore SDK库)上使用firestore。这看起来像我认为的速率限制问题,但我在Firebase上的设置是Blaze(按需付费),所以我应该偶尔看到这样的问题吗?

在我的开发过程中,清除缓存/等待/切换会话或浏览器似乎解决了这个问题。不知道为什么偶尔会发生这种情况,或者为什么周围的事情会解决它。

我目前在我的应用程序中已实现firebase.auth().signOut(),但每当发生这种情况时,注销并重新登录似乎无法解决问题。

这是我的开发者控制台堆栈跟踪问题:

index.js:2177 Firestore error -> Error: Missing or insufficient permissions.
    at new FirestoreError (error.js:149)
    at JsonProtoSerializer../node_modules/@firebase/firestore/dist/esm/src/remote/serializer.js.JsonProtoSerializer.fromRpcStatus (serializer.js:93)
    at JsonProtoSerializer../node_modules/@firebase/firestore/dist/esm/src/remote/serializer.js.JsonProtoSerializer.fromWatchChange (serializer.js:536)
    at PersistentListenStream../node_modules/@firebase/firestore/dist/esm/src/remote/persistent_stream.js.PersistentListenStream.onMessage (persistent_stream.js:389)
    at persistent_stream.js:331
    at persistent_stream.js:306
    at async_queue.js:83
    at <anonymous>
__stack_frame_overlay_proxy_console__ @ index.js:2177
(anonymous) @ SideMenu.js:91
Promise rejected (async)
componentDidUpdate @ SideMenu.js:88
commitLifeCycles @ react-dom.development.js:11517
commitAllLifeCycles @ react-dom.development.js:12294
callCallback @ react-dom.development.js:1299
invokeGuardedCallbackDev @ react-dom.development.js:1338
invokeGuardedCallback @ react-dom.development.js:1195
commitAllWork @ react-dom.development.js:12415
workLoop @ react-dom.development.js:12687
callCallback @ react-dom.development.js:1299
invokeGuardedCallbackDev @ react-dom.development.js:1338
invokeGuardedCallback @ react-dom.development.js:1195
performWork @ react-dom.development.js:12800
scheduleUpdateImpl @ react-dom.development.js:13185
scheduleUpdate @ react-dom.development.js:13124
enqueueSetState @ react-dom.development.js:9646
./node_modules/react/cjs/react.development.js.ReactComponent.setState @ react.development.js:218
onStateChange @ connectAdvanced.js:205
dispatch @ createStore.js:173
(anonymous) @ Utils.js:162
Promise resolved (async)
(anonymous) @ Utils.js:146
getGoogleCloudProjectsWithPromise @ Utils.js:115
(anonymous) @ AppMenu.js:126
Promise resolved (async)
finalizeLogin @ AppMenu.js:123
e.g @ auth.js:23
Yb @ auth.js:26
Ub @ auth.js:26
./node_modules/@firebase/auth/dist/auth.js.h.Mb @ auth.js:25
Cb @ auth.js:19
Promise resolved (async)
zb @ auth.js:18
yb @ auth.js:18
Vb @ auth.js:25
Eb @ auth.js:24
(anonymous) @ auth.js:19
(anonymous) @ auth.js:142
(anonymous) @ auth.js:138
qd @ auth.js:45
G @ auth.js:44
ef @ auth.js:77
./node_modules/@firebase/auth/dist/auth.js.h.fc @ auth.js:75
./node_modules/@firebase/auth/dist/auth.js.h.zb @ auth.js:75
XMLHttpRequest.send (async)
(anonymous) @ VM7143:1
Ye @ auth.js:73
./node_modules/@firebase/auth/dist/auth.js.Ch.m @ auth.js:138
Kh @ auth.js:137
(anonymous) @ auth.js:142
z @ auth.js:19
Qh @ auth.js:142
(anonymous) @ auth.js:153
e.g @ auth.js:23
Yb @ auth.js:26
Ub @ auth.js:26
./node_modules/@firebase/auth/dist/auth.js.h.Mb @ auth.js:25
Cb @ auth.js:19
Promise resolved (async)
zb @ auth.js:18
yb @ auth.js:18
Vb @ auth.js:25
Eb @ auth.js:24
A @ auth.js:20
./node_modules/@firebase/auth/dist/auth.js.h.get @ auth.js:181
./node_modules/@firebase/auth/dist/auth.js.pj.get @ auth.js:184
ml @ auth.js:240
ll @ auth.js:239
ul @ auth.js:242
(anonymous) @ auth.js:286
./node_modules/@firebase/app/dist/esm/src/firebaseApp.js.FirebaseAppImpl._getService @ firebaseApp.js:116
FirebaseAppImpl.(anonymous function) @ firebaseApp.js:303
(anonymous) @ auth.js:286
(anonymous) @ firebaseApp.js:323
callAppHooks @ firebaseApp.js:316
initializeApp @ firebaseApp.js:247
./src/redux/factory.js @ factory.js:49
__webpack_require__ @ bootstrap 6a68f7b55db27319f480:678
fn @ bootstrap 6a68f7b55db27319f480:88
./src/components/AppMenu.js @ Utils.js:170
__webpack_require__ @ bootstrap 6a68f7b55db27319f480:678
fn @ bootstrap 6a68f7b55db27319f480:88
./src/App.js @ fetch.js:461
__webpack_require__ @ bootstrap 6a68f7b55db27319f480:678
fn @ bootstrap 6a68f7b55db27319f480:88
./src/index.js @ Start.js:50
__webpack_require__ @ bootstrap 6a68f7b55db27319f480:678
fn @ bootstrap 6a68f7b55db27319f480:88
0 @ index.css?b74f:26
__webpack_require__ @ bootstrap 6a68f7b55db27319f480:678
./node_modules/@firebase/app/dist/esm/index.js.Object.defineProperty.value @ bootstrap 6a68f7b55db27319f480:724
(anonymous) @ bundle.js:728
index.js:2177 Firestore error -> Error: Missing or insufficient permissions.
    at new FirestoreError (error.js:149)
    at JsonProtoSerializer../node_modules/@firebase/firestore/dist/esm/src/remote/serializer.js.JsonProtoSerializer.fromRpcStatus (serializer.js:93)
    at JsonProtoSerializer../node_modules/@firebase/firestore/dist/esm/src/remote/serializer.js.JsonProtoSerializer.fromWatchChange (serializer.js:536)
    at PersistentListenStream../node_modules/@firebase/firestore/dist/esm/src/remote/persistent_stream.js.PersistentListenStream.onMessage (persistent_stream.js:389)
    at persistent_stream.js:331
    at persistent_stream.js:306
    at async_queue.js:83
    at <anonymous>
__stack_frame_overlay_proxy_console__ @ index.js:2177
(anonymous) @ SideMenu.js:91
Promise rejected (async)
componentDidUpdate @ SideMenu.js:88
commitLifeCycles @ react-dom.development.js:11517
commitAllLifeCycles @ react-dom.development.js:12294
callCallback @ react-dom.development.js:1299
invokeGuardedCallbackDev @ react-dom.development.js:1338
invokeGuardedCallback @ react-dom.development.js:1195
commitAllWork @ react-dom.development.js:12415
workLoop @ react-dom.development.js:12687
callCallback @ react-dom.development.js:1299
invokeGuardedCallbackDev @ react-dom.development.js:1338
invokeGuardedCallback @ react-dom.development.js:1195
performWork @ react-dom.development.js:12800
scheduleUpdateImpl @ react-dom.development.js:13185
scheduleUpdate @ react-dom.development.js:13124
enqueueSetState @ react-dom.development.js:9646
./node_modules/react/cjs/react.development.js.ReactComponent.setState @ react.development.js:218
onStateChange @ connectAdvanced.js:205
dispatch @ createStore.js:173
(anonymous) @ AppMenu.js:128
Promise resolved (async)
(anonymous) @ AppMenu.js:126
Promise resolved (async)
finalizeLogin @ AppMenu.js:123
e.g @ auth.js:23
Yb @ auth.js:26
Ub @ auth.js:26
./node_modules/@firebase/auth/dist/auth.js.h.Mb @ auth.js:25
Cb @ auth.js:19
Promise resolved (async)
zb @ auth.js:18
yb @ auth.js:18
Vb @ auth.js:25
Eb @ auth.js:24
(anonymous) @ auth.js:19
(anonymous) @ auth.js:142
(anonymous) @ auth.js:138
qd @ auth.js:45
G @ auth.js:44
ef @ auth.js:77
./node_modules/@firebase/auth/dist/auth.js.h.fc @ auth.js:75
./node_modules/@firebase/auth/dist/auth.js.h.zb @ auth.js:75
XMLHttpRequest.send (async)
(anonymous) @ VM7143:1
Ye @ auth.js:73
./node_modules/@firebase/auth/dist/auth.js.Ch.m @ auth.js:138
Kh @ auth.js:137
(anonymous) @ auth.js:142
z @ auth.js:19
Qh @ auth.js:142
(anonymous) @ auth.js:153
e.g @ auth.js:23
Yb @ auth.js:26
Ub @ auth.js:26
./node_modules/@firebase/auth/dist/auth.js.h.Mb @ auth.js:25
Cb @ auth.js:19
Promise resolved (async)
zb @ auth.js:18
yb @ auth.js:18
Vb @ auth.js:25
Eb @ auth.js:24
A @ auth.js:20
./node_modules/@firebase/auth/dist/auth.js.h.get @ auth.js:181
./node_modules/@firebase/auth/dist/auth.js.pj.get @ auth.js:184
ml @ auth.js:240
ll @ auth.js:239
ul @ auth.js:242
(anonymous) @ auth.js:286
./node_modules/@firebase/app/dist/esm/src/firebaseApp.js.FirebaseAppImpl._getService @ firebaseApp.js:116
FirebaseAppImpl.(anonymous function) @ firebaseApp.js:303
(anonymous) @ auth.js:286
(anonymous) @ firebaseApp.js:323
callAppHooks @ firebaseApp.js:316
initializeApp @ firebaseApp.js:247
./src/redux/factory.js @ factory.js:49
__webpack_require__ @ bootstrap 6a68f7b55db27319f480:678
fn @ bootstrap 6a68f7b55db27319f480:88
./src/components/AppMenu.js @ Utils.js:170
__webpack_require__ @ bootstrap 6a68f7b55db27319f480:678
fn @ bootstrap 6a68f7b55db27319f480:88
./src/App.js @ fetch.js:461
__webpack_require__ @ bootstrap 6a68f7b55db27319f480:678
fn @ bootstrap 6a68f7b55db27319f480:88
./src/index.js @ Start.js:50
__webpack_require__ @ bootstrap 6a68f7b55db27319f480:678
fn @ bootstrap 6a68f7b55db27319f480:88
0 @ index.css?b74f:26
__webpack_require__ @ bootstrap 6a68f7b55db27319f480:678
./node_modules/@firebase/app/dist/esm/index.js.Object.defineProperty.value @ bootstrap 6a68f7b55db27319f480:724
(anonymous) @ bundle.js:728
index.js:2177 Firestore error -> Error: Missing or insufficient permissions.
    at new FirestoreError (error.js:149)
    at JsonProtoSerializer../node_modules/@firebase/firestore/dist/esm/src/remote/serializer.js.JsonProtoSerializer.fromRpcStatus (serializer.js:93)
    at JsonProtoSerializer../node_modules/@firebase/firestore/dist/esm/src/remote/serializer.js.JsonProtoSerializer.fromWatchChange (serializer.js:536)
    at PersistentListenStream../node_modules/@firebase/firestore/dist/esm/src/remote/persistent_stream.js.PersistentListenStream.onMessage (persistent_stream.js:389)
    at persistent_stream.js:331
    at persistent_stream.js:306
    at async_queue.js:83
    at <anonymous>
__stack_frame_overlay_proxy_console__ @ index.js:2177
(anonymous) @ SideMenu.js:91
Promise rejected (async)
componentDidUpdate @ SideMenu.js:88
commitLifeCycles @ react-dom.development.js:11517
commitAllLifeCycles @ react-dom.development.js:12294
callCallback @ react-dom.development.js:1299
invokeGuardedCallbackDev @ react-dom.development.js:1338
invokeGuardedCallback @ react-dom.development.js:1195
commitAllWork @ react-dom.development.js:12415
workLoop @ react-dom.development.js:12687
callCallback @ react-dom.development.js:1299
invokeGuardedCallbackDev @ react-dom.development.js:1338
invokeGuardedCallback @ react-dom.development.js:1195
performWork @ react-dom.development.js:12800
scheduleUpdateImpl @ react-dom.development.js:13185
scheduleUpdate @ react-dom.development.js:13124
enqueueSetState @ react-dom.development.js:9646
./node_modules/react/cjs/react.development.js.ReactComponent.setState @ react.development.js:218
onStateChange @ connectAdvanced.js:205
dispatch @ createStore.js:173
routeAfterLogin @ AppMenu.js:200
(anonymous) @ AppMenu.js:129
Promise resolved (async)
(anonymous) @ AppMenu.js:126
Promise resolved (async)
finalizeLogin @ AppMenu.js:123
e.g @ auth.js:23
Yb @ auth.js:26
Ub @ auth.js:26
./node_modules/@firebase/auth/dist/auth.js.h.Mb @ auth.js:25
Cb @ auth.js:19
Promise resolved (async)
zb @ auth.js:18
yb @ auth.js:18
Vb @ auth.js:25
Eb @ auth.js:24
(anonymous) @ auth.js:19
(anonymous) @ auth.js:142
(anonymous) @ auth.js:138
qd @ auth.js:45
G @ auth.js:44
ef @ auth.js:77
./node_modules/@firebase/auth/dist/auth.js.h.fc @ auth.js:75
./node_modules/@firebase/auth/dist/auth.js.h.zb @ auth.js:75
XMLHttpRequest.send (async)
(anonymous) @ VM7143:1
Ye @ auth.js:73
./node_modules/@firebase/auth/dist/auth.js.Ch.m @ auth.js:138
Kh @ auth.js:137
(anonymous) @ auth.js:142
z @ auth.js:19
Qh @ auth.js:142
(anonymous) @ auth.js:153
e.g @ auth.js:23
Yb @ auth.js:26
Ub @ auth.js:26
./node_modules/@firebase/auth/dist/auth.js.h.Mb @ auth.js:25
Cb @ auth.js:19
Promise resolved (async)
zb @ auth.js:18
yb @ auth.js:18
Vb @ auth.js:25
Eb @ auth.js:24
A @ auth.js:20
./node_modules/@firebase/auth/dist/auth.js.h.get @ auth.js:181
./node_modules/@firebase/auth/dist/auth.js.pj.get @ auth.js:184
ml @ auth.js:240
ll @ auth.js:239
ul @ auth.js:242
(anonymous) @ auth.js:286
./node_modules/@firebase/app/dist/esm/src/firebaseApp.js.FirebaseAppImpl._getService @ firebaseApp.js:116
FirebaseAppImpl.(anonymous function) @ firebaseApp.js:303
(anonymous) @ auth.js:286
(anonymous) @ firebaseApp.js:323
callAppHooks @ firebaseApp.js:316
initializeApp @ firebaseApp.js:247
./src/redux/factory.js @ factory.js:49
__webpack_require__ @ bootstrap 6a68f7b55db27319f480:678
fn @ bootstrap 6a68f7b55db27319f480:88
./src/components/AppMenu.js @ Utils.js:170
__webpack_require__ @ bootstrap 6a68f7b55db27319f480:678
fn @ bootstrap 6a68f7b55db27319f480:88
./src/App.js @ fetch.js:461
__webpack_require__ @ bootstrap 6a68f7b55db27319f480:678
fn @ bootstrap 6a68f7b55db27319f480:88
./src/index.js @ Start.js:50
__webpack_require__ @ bootstrap 6a68f7b55db27319f480:678
fn @ bootstrap 6a68f7b55db27319f480:88
0 @ index.css?b74f:26
__webpack_require__ @ bootstrap 6a68f7b55db27319f480:678
./node_modules/@firebase/app/dist/esm/index.js.Object.defineProperty.value @ bootstrap 6a68f7b55db27319f480:724
(anonymous) @ bundle.js:728

以下是我的数据存储安全规则:

service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write: if false;
    }
    match /dev/organizations/{orgId} {
        allow read;
      match /beacon-providers/{providerId} {
        // allow read, write: if auth.ordId = orgId
        // @TODO also check if user is an admin in the current org
        allow read, write: if orgId == 'incubation'
      }    
    }
    match /organizations/{orgId} {
      allow read, write: if orgId == 'incubation';
      match /beacon-providers {
        allow read, write;
        match /{providerId} {
                    //allow read: if resource.data.user_uid == request.auth.uid;
                    allow read,write;
        }
      }
    }
  }
}

0 个答案:

没有答案