Unable to secure firebase using Tagged Users

Database & APIs

I am having problems securing access to a userimages collection which is a sub collection of users.

If I set the sub collection to authenticated users it works fine, the moment I select tagged users I get this error in the app

Run mode-only notification:

Firestore Security Rules Error on userImages: Missing or insufficient permissions

Here is my existing ruleset. Tagged users is set to a create_by field in the userImages collection. I have manually checked the collection on firebase and can see a document with the created_by set to a uid I would expect.



These match on both firestore and within flutterflow so are in sync.

What I am trying to achieve is to allow users to create their own documents, and only they should be able to see (read) and edit those documents, not other users.

I have followed through a few guides and as far as I can see the above should work, so not sure what I am missing?

Thanks

What have you tried so far?

I have also tried selecting the tagged user from the parent, i.e. the below configuration. But get exactly the same issue

rules_version = '2';

service cloud.firestore {

match /databases/{database}/documents {

match /users/{document} {

allow create: if request.auth.uid == document;

allow read: if request.auth.uid == document;

allow write: if request.auth.uid == document;

allow delete: if false;

}

match /images/{document} {

allow create: if request.auth != null;

allow read: if request.auth != null;

allow write: if false;

allow delete: if false;

}

match /users/{parent}/userImages/{document} {

allow create: if request.auth != null;

allow read: if request.auth.uid == get(/databases/$(database)/documents/users/$(parent)).data.uid;

allow write: if request.auth.uid == get(/databases/$(database)/documents/users/$(parent)).data.uid;

allow delete: if request.auth.uid == get(/databases/$(database)/documents/users/$(parent)).data.uid;

}

}

}

Did you check FlutterFlow's Documentation for this topic?
Yes
2 replies