I have a document in Firebase structured like so:
{
applications: {
id_1: {
feature: {
a: true,
b: false
},
users: ['user_id_1', 'user_id_2']
}
}
}
I want to add a rule that ensures only users in the users
array can read and write to the application with id === id_1
.
I have tried adding the following rules but still seem to be able to read and write data when logged in as user_id_3
{
"rules": {
".read": "now < 1643846400000", // 2022-2-3
".write": "now < 1643846400000", // 2022-2-3,
"applications": {
"$appId": {
".write": "data.child('users').hasChild(auth.uid)",
".read": "data.child('users').hasChild(auth.uid)"
}
}
}
}
How can I add a rule to give access to a group of users?