-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfirestore.rules
91 lines (71 loc) · 2.46 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
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 request.auth.uid == uid;
}
}
match /commerce/{version} {
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;
}
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 /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 'write' in get(/databases/$(database)/documents/commerce/$(version)/providers/$(provider_id)/members/$(request.auth.uid)).data.permissions;
}
allow read: if true;
allow write: if request.auth.uid == provider_id || isOwner();
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 /products/{product_id} {
allow read: if true;
allow write: if request.auth.uid == provider_id || isOwner() || isEditor();
match /skus/{sku_id} {
allow read: if true;
allow write: if request.auth.uid == provider_id || isOwner() || isEditor();
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 /social/{version} {
match /users/{uid} {
allow read: if true;
allow write: if request.auth.uid == uid;
}
}
}
}