-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfirestore.rules
More file actions
71 lines (59 loc) · 2.15 KB
/
firestore.rules
File metadata and controls
71 lines (59 loc) · 2.15 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
// Fonction pour vérifier si l'utilisateur est un administrateur
function isAdmin() {
return request.auth != null && exists(/databases/$(database)/documents/admins/$(request.auth.uid));
}
// Accès aux documents d'administration
match /admins/{userId} {
allow read: if request.auth != null && request.auth.uid == userId;
allow write: if false;
}
// Profils utilisateurs et sous-collections privées
match /users/{userId} {
allow read: if request.auth != null;
allow create, update: if request.auth != null && request.auth.uid == userId;
match /notes/{noteId} {
allow read, write: if request.auth != null && request.auth.uid == userId;
}
match /progress/{resourceId} {
allow read, write: if request.auth != null && request.auth.uid == userId;
}
}
// Ressources, Parcours et Certifications
match /resources/{resourceId} {
allow read: if request.auth != null;
allow write: if isAdmin();
}
match /learningPaths/{pathId} {
allow read: if request.auth != null;
allow write: if isAdmin();
}
match /certifications/{certId} {
allow read: if request.auth != null;
allow write: if isAdmin();
}
// Feedback
match /feedback/{feedbackId} {
allow create: if request.auth != null && request.auth.uid == request.resource.data.userId;
allow read, update, delete: if isAdmin();
}
// Espace Communautaire (Chat)
match /community_messages/{messageId} {
allow read: if request.auth != null;
allow create: if request.auth != null
&& request.resource.data.userId == request.auth.uid
&& request.resource.data.text is string
&& request.resource.data.text.size() <= 1000;
allow delete: if isAdmin();
}
// Autorisation des requêtes de groupe de collection
match /{path=**}/progress/{resourceId} {
allow read: if isAdmin();
}
match /{path=**}/notes/{noteId} {
allow read: if isAdmin();
}
}
}