4
votes

Firestore security rule

allow list: if request.query.limit <=30
&& request.query.orderBy == 'date'

Android code

db.collection(COL)
.orderBy("date", Direction.DESCENDING)
.limit(30)
.get()

The above code works fine when I removed request.query.orderBy in security rule.

How to fix it?

1
Can you show the code that doesn't work against these rules? - Frank van Puffelen
Hi Frank, thanks for the response. I updated the code in the question. - A K
Hmm.... I'm not sure what's going wrong there. Upvoted in hopes that somebody else spots the problem. - Frank van Puffelen
ok... thanks! I found the same question posted by another user, but still there is no answer. Can you please test request.query.orderBy working as expected or not. - A K

1 Answers

3
votes

I found the answer.

We should treat request.query.orderBy has Map.

request.query.orderBy.date == 'DESC'