-
Notifications
You must be signed in to change notification settings - Fork 24
/
firestore.rules
110 lines (94 loc) · 3.41 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
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
// ---------------------------------------------------------
// Rowy rules start
// ---------------------------------------------------------
// Automatically generated and managed by Rowy
// ⚠️ Do not edit this block directly, as it will be overwritten
// To edit the security rules, please do it on different block or manage from rowy settings
// initialized on 5/25/2023
match /{collectionId}/{docId} {
allow read: if colRule(["homepage-collection"], ["ADMIN","EDITOR","VIEWER","OWNER"]);
allow create, update, delete: if colRule(["homepage-collection"], ["ADMIN","OWNER"]);
match /{subTableCollectionID}/{document=**}{
allow read: if colRule(["homepage-collection"], ["ADMIN","EDITOR","VIEWER","OWNER"]);
allow create, update, delete: if colRule(["homepage-collection"], ["ADMIN","OWNER"]);
}
function colRule(collections, roles){
return collectionId in collections && hasAnyRole(roles);
}
}
match /{somePath=**}/{collectionGroupId}/{docId}{
allow read, create, update, delete: if colRule(["recent_items","homepage/collection/items"], ["ADMIN","OWNER"]);
function colRule(collections, roles){
return collectionGroupId in collections && hasAnyRole(roles);
}
}
// ---------------------------------------------------------
// Rowy rules end
// ---------------------------------------------------------
// Allow admins to read and write all documents
match /{document=**} {
allow read, write: if hasAnyRole(["ADMIN", "OWNER"]);
}
// Rowy: Allow signed in users to read Rowy configuration and admins to write
match /_rowy_/{docId} {
allow read: if request.auth.token.roles.size() > 0;
allow write: if hasAnyRole(["ADMIN", "OWNER"]);
match /{document=**} {
allow read: if request.auth.token.roles.size() > 0;
allow write: if hasAnyRole(["ADMIN", "OWNER"]);
}
match /schema/{tableId} {
allow update: if canModify(tableId,'pc')
match /{document=**} {allow read,write: if canModify(tableId,'pc')}
}
match /groupSchema/{tableId} {
allow update: if canModify(tableId,'cg')
match /{document=**} {allow read,write: if canModify(tableId,'cg')}
}
function canModify(tableId,tableType) {
return hasAnyRole(get(/databases/$(database)/documents/_rowy_/settings)
.data.tablesSettings[tableType][tableId].modifiableBy)
}
}
// Rowy: Allow users to edit their settings
match /_rowy_/userManagement/users/{userId} {
allow get, update, delete: if isDocOwner(userId);
allow create: if request.auth.token.roles.size() > 0;
}
// Rowy: Allow public to read public Rowy configuration
match /_rowy_/publicSettings {
allow get: if true;
}
// Rowy: Utility functions
function isDocOwner(docId) {
return request.auth != null && (request.auth.uid == resource.id || request.auth.uid == docId);
}
function hasAnyRole(roles) {
return request.auth != null && request.auth.token.roles.hasAny(roles);
}
match /homepage/ids {
allow read: if true;
}
match /homepage-collection/{document=**} {
allow read, write: if true;
}
match /homepage-collection-debug/{document=**} {
allow read, write: if true;
}
match /downloads/{document=**} {
allow read, write: if true;
}
match /homepage/{document=**} {
allow read, write: if true;
}
match /feedback/{document=**} {
allow read, write: if true;
}
match /{document=**} {
allow read, write: if request.auth != null;
}
}
}