Reputation: 133
I have security rule write like this :
/databases/{database}/documents {
match /collection_COUNTRY_EN/{docId} {
allow....
}
match /collection_COUNTRY_ES/{docId} {
allow...
}
}
Where the rule are identical to all the country. Is there a way to implement regex in the match /path to have the same rule for all the collection that start with something and end with a country code ? Or does i have to structure my data in a different way ?
Thanks for your time.
Upvotes: 0
Views: 627
Reputation: 317412
Security rules do not support regex in the path match. You can only wildcard on the full name of a path segment.
What you might want to do instead is organize all your common top-level collection into subcollections organized under a known document, and apply the same rules to each of them that way:
match /countries/data/{countryCollection}/{docId} {
allow...
}
This would apply the same permissions to all country subcollections organized under /countries/data, which can be an empty document, or even a non-existent document.
Upvotes: 1