Skip to content

Instantly share code, notes, and snippets.

@codewithahad01
Forked from bradtraversy/firebase_rules.txt
Created May 13, 2022 16:53
Show Gist options
  • Save codewithahad01/7f4d982ad1e1f997cac26818dddbf65a to your computer and use it in GitHub Desktop.
Save codewithahad01/7f4d982ad1e1f997cac26818dddbf65a 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