Skip to content

Commit

Permalink
add firestore security rules
Browse files Browse the repository at this point in the history
  • Loading branch information
Roman Abendroth committed Nov 10, 2023
1 parent 0dde088 commit 062cf63
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
3 changes: 3 additions & 0 deletions firebase.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,8 @@
"enabled": true
},
"singleProjectMode": true
},
"firestore": {
"rules": "rules/firestore.rules"
}
}
28 changes: 28 additions & 0 deletions rules/firestore.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
rules_version = '2';

service cloud.firestore {
match /databases/{database}/documents {
function isAuthenticated() {
return request.auth != null;
}


match /plants/{plantId} {
function isOwner() {
return request.auth.uid == resource.data.owner;
}

allow read: if isAuthenticated() && isOwner();
allow write: if false;
allow create: if false;
allow update: if false;
}

match /notifications/{notificationId} {
allow read: if isAuthenticated();
allow write: if false;
allow create: if false;
allow update: if false;
}
}
}

0 comments on commit 062cf63

Please sign in to comment.