rules_version = '2'; service cloud.firestore { match /databases/{database}/documents { match /docs/{docId} { // accessMap/{userId}/{docId} is a map of users to documents they can access allow read if exists(docPath("accessMap/$(request.auth.uid)/docs/$(docId)")); } /** * Shortcut to simplify pathing; make sure this exists inside the match /databases block */ function getPath(childPath) { return path('/databases/'+database+'/documents/'+childPath) } } }