Skip to content

Instantly share code, notes, and snippets.

@edoves
Created November 5, 2022 08:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edoves/5df30085507bdbab4caa1402ac9b0b41 to your computer and use it in GitHub Desktop.
Save edoves/5df30085507bdbab4caa1402ac9b0b41 to your computer and use it in GitHub Desktop.
Firebase rules for house marketplace app
// FIRESTORE RULES
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
// Listings
match /listings/{listing} {
allow read;
allow create: if request.auth != null && request.resource.data.imgUrls.size() < 7;
allow delete: if resource.data.userRef == request.auth.uid;
allow update: if resource.data.userRef == request.auth.uid;
}
// Users
match /users/{user} {
allow read;
allow create;
allow update: if request.auth.uid == user
}
}
}
// STORAGE RULES
rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
match /{allPaths=**} {
allow read;
allow write: if
request.auth != null &&
request.resource.size < 2 * 1024 * 1024 && //2MB
request.resource.contentType.matches('image/.*')
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment