-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfirestore.rules
More file actions
56 lines (48 loc) · 2.87 KB
/
Copy pathfirestore.rules
File metadata and controls
56 lines (48 loc) · 2.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
// Users can only read/write their own settings
match /settings/{userId} {
allow read, write: if request.auth != null && request.auth.uid == userId;
}
// Transactions: users can only CRUD their own
match /transactions/{transactionId} {
allow read: if request.auth != null && resource.data.userId == request.auth.uid;
allow create: if request.auth != null && request.resource.data.userId == request.auth.uid;
allow update: if request.auth != null && resource.data.userId == request.auth.uid && request.resource.data.userId == resource.data.userId;
allow delete: if request.auth != null && resource.data.userId == request.auth.uid;
}
// Categories: users can only CRUD their own
match /categories/{categoryId} {
allow read: if request.auth != null && resource.data.userId == request.auth.uid;
allow create: if request.auth != null && request.resource.data.userId == request.auth.uid;
allow update: if request.auth != null && resource.data.userId == request.auth.uid && request.resource.data.userId == resource.data.userId;
allow delete: if request.auth != null && resource.data.userId == request.auth.uid;
}
// Budgets: users can only CRUD their own
match /budgets/{budgetId} {
allow read: if request.auth != null && resource.data.userId == request.auth.uid;
allow create: if request.auth != null && request.resource.data.userId == request.auth.uid;
allow update: if request.auth != null && resource.data.userId == request.auth.uid && request.resource.data.userId == resource.data.userId;
allow delete: if request.auth != null && resource.data.userId == request.auth.uid;
}
// Savings Goals: users can only CRUD their own
match /savingsGoals/{goalId} {
allow read: if request.auth != null && resource.data.userId == request.auth.uid;
allow create: if request.auth != null && request.resource.data.userId == request.auth.uid;
allow update: if request.auth != null && resource.data.userId == request.auth.uid && request.resource.data.userId == resource.data.userId;
allow delete: if request.auth != null && resource.data.userId == request.auth.uid;
}
// Recurring Transactions: users can only CRUD their own
match /recurringTransactions/{recurringId} {
allow read: if request.auth != null && resource.data.userId == request.auth.uid;
allow create: if request.auth != null && request.resource.data.userId == request.auth.uid;
allow update: if request.auth != null && resource.data.userId == request.auth.uid && request.resource.data.userId == resource.data.userId;
allow delete: if request.auth != null && resource.data.userId == request.auth.uid;
}
// Deny everything else
match /{document=**} {
allow read, write: if false;
}
}
}