How do I configure permissions so that a user can only read and write documents where they are the owner? my documents have a top level attribute called owner.
I read these docs
https://firebase.google.com/docs/firestore/security/secure-data?authuser=0#the_resource_variable
and it seems like this should work?
service cloud.firestore {
match /databases/{database}/documents {
match /analysis/{analysis} {
allow read, write: if request.auth.email == resource.data.owner
}
}
}
however this doesn't seem to work. i continuously get insufficient permission error. What do i need to change?
Update:
After reading the docs @Doug Stevenson linked I decided to go with
service cloud.firestore {
match /databases/{database}/documents {
match /analysis/{analysis} {
allow read, write: if request.auth.uid == resource.data.owner_uid;
}
}
}
So my original intent was that when we do a list operation:
a. only those documents belonging to a user are returned
b. only documents a user owns can be read or written by that user.
With the above configuration b. is accomplished.
how do I do accomplish a. ?