8.6.2 breaks auth/firestore rules
[REQUIRED] Describe your environment
- Operating System version: Mac OS X
- Browser version: Chrome
- Firebase SDK version: 8.6.2
- Firebase Product: auth
[REQUIRED] Describe the problem
After upgrading from firebase 8.6.1 → 8.6.2, I get the "ERROR FirebaseError: Missing or insufficient permissions." error when trying to access protected docs/collections. Rolling back to 8.6.1 fixes the issue.
Steps to reproduce:
Upgrade from Firebase 8.6.1 → 8.6.2 My app is running on Angular 12
I can reproduce, I had to roll back https://github.com/k0swe/forester/pull/395. Same symptom, ERROR FirebaseError: Missing or insufficient permissions appears in the JS console when trying to access documents. Rolling back fixes.
Hi @mazlano27, I wasn't able to reproduce the error using the SDK version 8.6.2. Would you mind sharing a minimal, but complete sample project or code snippet that I can run locally to replicate the issue? Also, please include a sample Firestore security rules.
I'm seeing this as well
From 8.6.1 to 8.6.2 I see:
TypeError: t.onInit is not a function
I believe its related to auth as well.
Hi @mazlano27, I wasn't able to reproduce the error using the SDK version 8.6.2. Would you mind sharing a minimal, but complete sample project or code snippet that I can run locally to replicate the issue? Also, please include a sample Firestore security rules.
I'm attempting to create a reproducible, minimal sample on Stackblitz, to no avail so far. Others, please feel free to fork it and see if we can isolate the issue.
In the meantime, I have a reasonably simple reproduction with my real app:
- Clone https://github.com/k0swe/forester
npm installng serve -o- Log in with a Google account
- Create an empty logbook (any name)
- You are taken to the logbook view. There should be no console errors about Firebase. (Might be some about websockets that I need to clean up)
Now to reproduce the undesired behavior:
npm install [email protected] --save-exactng serve -o- Back on the Forester main page, click on your logbook
- On the logbook view, the console now has
ERROR FirebaseError: Missing or insufficient permissions.
Now that I think of it, the security rules for this Firestore are such that the logbook collection is accessed by an array of editor IDs. Maybe the Firestore client is short-circuiting the security check when it can't tell if reading the logbook will succeed?
I have the same issue on my side. I've downgraded to 8.6.1 and it solves the issue.
I couldn't write to Firestore. I've been fighting for hours thinking it was my fault. I desperately found this thread. What a relief!
I have the same issue in my project. Hopefully there's a fix coming quickly. For now I pinned on an older version of firebase.
Thanks for the repro app! I'll bring this up with the team, tracking internally at b/189114894
Perhaps related? https://github.com/angular/angularfire/issues/2838
Facing the same issue in firebase version 9 beta 2 as well it seems the only way to fix it is to basically have the security rules set to if true, which is a bad idea.
apparently adding the outhstate listener fixes my issue in particular.
My guess would be that this is a "race-condition" due to how Firestore interacts with lazy-loaded Auth (per @angular/fire's current design), adding the authState listener or a route guard should ensure that the Angular component is loaded and auth initialized prior to Firestore usage. I wouldn't call that a work around, as it just decreases the likelihood that you experience this issue, if it is infact a race condition.
FWIW for v9 beta 2, we're taking a new approach in AngularFire (see 7.0.0-alpha.0) the main entries are no longer lazy-loaded, that will be entirely up to the developer now that we have tree-shaking. In the upcoming AngularFire 6.2 (https://github.com/angular/angularfire/pull/2679) and 7.0.0-alpha.1 (compat) I'll have a proper work-around for lazy loaded auth+firestore, in that AngularFire will have lazy-loaded variant of AngularFirestore which will be able to force AngularFireAuth to be initialized prior to AngularFirestore (if it's being used).
I'm still experiencing these symptoms as of v8.6.3 in https://github.com/k0swe/forester/pull/412.
My guess would be that this is a "race-condition" due to how Firestore interacts with lazy-loaded Auth (per
@angular/fire's current design), adding the authState listener or a route guard should ensure that the Angular component is loaded and auth initialized prior to Firestore usage. I wouldn't call that a work around, as it just decreases the likelihood that you experience this issue, if it is infact a race condition.
FYI: I'm also experiencing this issue with v8.6.2 & v8.6.3. In my case the Firestore call is made from a lazy loaded module with a route guard. If it helps, I can share my repo with you @jamesdaniels
Still facing this issue is 8.6.5
I'm getting the same error on any FireStore access attempt, but it ONLY happens in Chrome. Works fine in Firefox.
works on 8.6.1, anything newer is toast.
---Version 8.6.7 seems to be better, I think #4971 was effective.---
Edit: it wasn't effective, I was testing in Firefox which is not affected. My app is still broken at 8.6.8 when run in Chrome.