We know how to write secure rules to limit actions on a collection, but, how to deny creations of new collections?
To allow only writing to specific collections in your security rules is a two-step process
For example (allowing access to a users
collection only):
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if false;
}
match /users/{userId} {
allow read, update, delete: if request.auth != null && request.auth.uid == userId;
allow create: if request.auth != null;
}
}
}