-
-
Notifications
You must be signed in to change notification settings - Fork 293
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IMPORTANT: Deploy Security Rules #26
Conversation
I think that's a good start for now. I would add rules to prevent creating unwanted entities (read/write not allowed by default) so nobody can create "unwantedmessage" doc on our db. Forcing us to check all permissions on all new entities preventing any security lack.
|
You are right @edguerrade I extended the rule set a bit more, because otherwise users wouldn't be able to read messages anymore (line 18), because of the cascading nature of the rule set. Let me know what you think about it:
Reading on Do you think that's fine then? I went through the simulator once to check whether everything is alright, but would be great if someone else would try it as well :) |
Hey @rwieruch
|
@Param-Harrison are you sure your problem is related to the security rules? |
@rwieruch I will test it again and tweak a bit to check it. |
so basically this line in
|
Ah correct, that's because a user isn't able anymore to retrieve all users from the database to associate them with the messages. The security rules forbid it. That's why I removed this features from the code as well. Check the PR again to see the changes. If you want to get the associated users to a message, I would recommend to save minimal user information to the message entity (e.g. message owner's name). As Alternative, you could also query every single user associated to a message. Since this could become a bottleneck eventually, you may want to deduplicate doubled users to minimize the queries (e.g. two messages are written by one user id, fetch this user only once from Firebase to associate the user with the message). |
Got it 👍 |
Merged! And merged changes into the other projects as well. In case of the Firestore project, any help is super appreciated to convert the security rules over to their syntax: the-road-to-react-with-firebase/react-firestore-authentication#10 |
Ref.: #23 CC @edguerrade
The PR addresses the main issue of having users full control of reading and writing from/to the database. The following security rules that you can set up on your Firebase Dashboard should work:
Basically that's what the first commit (2a895f9) of this PR is doing, because we need a roles object instead of array in the database to apply the shown rules. With this change comes the restriction that users cannot fetch all users on the home page anymore to associate them with messages (52d24d0). The third commit gives only message owners the ability to edit/delete messages in the UI, otherwise there would be an error due to the new security rules (8cb594e).
Let me know your thoughts!
If anyone wants to help me out with this security issue, all of the changes need to be applied to the other Firebase repositories as well:
Note for myself: