I'd like to add a Firestore security rule that allows a collection group query, but only if there's a where clause on the id field. In essence, I'm like to allow the user to retrieve the document only if s/he knows the id.
In other words, I'd like to allow this:
db.collectionGroup('widgets').where('id', '==', '123').get()
...but not this:
db.collectionGroup('widgets').get()
The security rule would look something like this:
match /{path=**}/widgets/{widgetId} {
allow list: if request.query.keys().hasAny(['id']);
}
Is there a way to do this?