I'm struggling with the Firestore security rules. This is the struct for my users collection and I also have structures for other collections: machines, logs, and photos. I want to set up the rule such that data can be accessed only when the request.auth.uid == user.user_UUID
I presume my syntax must not be correct in my rule because with what I have below, I'm not able to read or write any data after I log in with me app. thinking that maybe the brackets around the user_UUID were the problemI tried changing 'match users/{user_UUID}' to 'match users/user_UUID' but that didn't work. I also tried removing the 'match /{document=**} '
each of my collections have a user_UUID field and I want security to protect such that only the respective authenticated user can access that data.
import Foundation
struct User: Codable {
var email: String?
var userUUID: String?
}
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
match /users/{user_UUID} {
allow read, update, delete: if request.auth != null && request.auth.uid == user_UUID;
allow create: if request.auth != null;
}
}
}
}