I currently have security rules that allow a user to read only from a collection named "153".
In Android, I access Firestore and call .collection("153").get()...
on the Firestore instance to retrieve data from that collection.
If, instead, the Android code reads .collection("999").get...
, the permission is denied, as it should be.
Security Rules:
service cloud.firestore {
match /databases/{database}/documents {
// FULL ADMIN ACCESS
match /{document=**} {
allow read, write: if request.auth.uid == 'XYZ1234XYEDFC';
}
// 153 READ
match /153/{x} {
allow read: if request.auth.uid == 'XYZ12234XTZ';
}
// 999 READ
match /999/{x} {
allow read: if request.auth.uid == 'ABC1234ABC';
}
}
}
What is the method to allow an app user, who is signed in via Firestore, to only read a collection they have access to in Security Rules without hardcoding the collection?
Edit:
I have an existing database in Firestore. The database has many top-level collections with documents in each. Each app user will have access to one or many of the collections.
Right now, I can only see how to call upon a specific collection by giving the collection path. Can I get all collections that a UID has access to, programmatically?