-
Notifications
You must be signed in to change notification settings - Fork 10
/
firestore.rules
135 lines (105 loc) · 3.96 KB
/
firestore.rules
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
rules_version = "2";
service cloud.firestore {
match /databases/{database}/documents {
match /account/{version} {
match /accounts/{uid} {
allow read: if request.auth.uid == uid;
allow write: if false;
}
match /requirements/{uid} {
allow read: if request.auth != null;
allow write: if false;
}
}
match /commerce/{version} {
match /customers/{uid} {
allow read: if request.auth.uid == uid;
allow write: if false;
}
match /users/{uid} {
allow read: if request.auth.uid == uid;
allow write: if request.auth.uid == uid;
match /providers/{provider_id} {
allow read: if request.auth.uid == uid;
allow write: if false;
}
match /orders/{order_id} {
allow read: if request.auth.uid == uid;
allow write: if false;
}
match /shippingAddresses/{shipping_id} {
allow read: if request.auth.uid == uid;
allow write: if request.auth.uid == uid;
}
}
match /carts/{uid} {
allow read: if request.auth.uid == uid;
allow write: if request.auth.uid == uid;
}
match /providerDrafts/{provider_id} {
function isOwner() {
return "owner" in get(/databases/$(database)/documents/commerce/$(version)/providers/$(provider_id)/members/$(request.auth.uid)).data.permissions;
}
function isEditor() {
return "write" in get(/databases/$(database)/documents/commerce/$(version)/providers/$(provider_id)/members/$(request.auth.uid)).data.permissions;
}
function isViewer() {
return "read" in get(/databases/$(database)/documents/commerce/$(version)/providers/$(provider_id)/members/$(request.auth.uid)).data.permissions;
}
allow read: if request.auth.uid == provider_id || isOwner() || isEditor() || isViewer();
allow write: if request.auth.uid == provider_id || isOwner() || isEditor();
}
match /providers/{provider_id} {
function isOwner() {
return "owner" in get(/databases/$(database)/documents/commerce/$(version)/providers/$(provider_id)/members/$(request.auth.uid)).data.permissions;
}
function isEditor() {
return "write" in get(/databases/$(database)/documents/commerce/$(version)/providers/$(provider_id)/members/$(request.auth.uid)).data.permissions;
}
function isViewer() {
return "read" in get(/databases/$(database)/documents/commerce/$(version)/providers/$(provider_id)/members/$(request.auth.uid)).data.permissions;
}
allow read: if true;
allow write: if false;
match /members/{user_id} {
allow read: if request.auth.uid == provider_id || isOwner() || isEditor() || isViewer();
allow write: if request.auth.uid == provider_id || isOwner();
}
match /productDrafts/{product_id} {
allow read: if request.auth.uid == provider_id || isOwner() || isEditor() || isViewer();
allow write: if request.auth.uid == provider_id || isOwner() || isEditor();
match /skus/{sku_id} {
allow read: if request.auth.uid == provider_id || isOwner() || isEditor() || isViewer();
allow write: if request.auth.uid == provider_id || isOwner() || isEditor();
}
}
match /products/{product_id} {
allow read: if true;
allow write: if false;
match /skus/{sku_id} {
allow read: if true;
allow write: if false;
match /stocks/{shard_key} {
allow read: if true;
allow write: if false;
}
}
}
match /orders/{order_id} {
allow read: if request.auth.uid == provider_id || isOwner() || isEditor() || isViewer();
allow write: if request.auth.uid == provider_id || isOwner() || isEditor();
match /activities/{activity_id} {
allow read: if request.auth.uid == provider_id || isOwner() || isEditor() || isViewer();
allow write: if request.auth.uid == provider_id || isOwner() || isEditor();
}
}
}
}
match /social/{version} {
match /users/{uid} {
allow read: if true;
allow write: if request.auth.uid == uid;
}
}
}
}