GCP Firestore Security Rules Not Applying as Expected with Flutter Web App
I keep running into I'm optimizing some code but I'm working on a Flutter web app that uses Google Cloud Firestore for real-time data synchronization. I've set up some security rules to restrict read and write access based on user roles, but I'm noticing that these rules don't seem to be applied correctly. For instance, I have the following security rules: ```plaintext service cloud.firestore { match /databases/{database}/documents { match /users/{userId} { allow read, write: if request.auth.uid == userId; } match /publicData/{docId} { allow read; } } } ``` I am authenticated using Firebase Authentication, and I can confirm that `request.auth.uid` is returning the expected user ID. However, when I try to read from the `/users/{userId}` collection, I get the following behavior: ``` FirebaseError: The caller does not have permission ``` This happens even when I am logged in as the correct user. I’ve also tried using the Firestore emulator for local testing, and the behavior is the same. I've verified that my user has the required role set in Firebase Authentication, but I still encounter this scenario. To debug, I tried adding a logging statement within the Firestore rules to check the value of `request.auth.uid`, but I don't see any output in my logs. I’ve also checked the Firestore console for any potential misconfigurations, but everything seems to be in order. Has anyone experienced similar issues with Firestore security rules in a Flutter web app? What could be going wrong here? Any suggestions for troubleshooting or tips on best practices for structuring Firestore rules would be greatly appreciated! What's the best practice here? I recently upgraded to Dart LTS. I'm open to any suggestions. Am I approaching this the right way?