-
Notifications
You must be signed in to change notification settings - Fork 13
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
Firestore Security #36
Comments
Without authentication, it'll be difficult to write rules that'll be effective, but what we can do for now to step up security is:
What I'll suggest is most important now is to add some form of validation for creation of listings. For the issue of allowing GitHub developers to run locally on their machine, consider adding a development environment for developers instead of as mentioned in #24. Meanwhile, if you can provide the database structure, along with a data dictionary, that'll help immensely, thanks |
Thanks for the amazing tips! Implementing 2 right now. How can the validation be done? :) Do you mean through Firebase rules or through frontend checks? Thank you! |
Also added a brief database structure with data dictionary in the README. If more is needed do let me know :) |
You can write validations in the rules itself, for such operations you can refer to here (i.e. We can check if price is indeed a number by allowing them write access if For point 3, it depends on how your data is stored, from a brief read through of your forms, it seems that you're relying on Firestore to generate a unique document ID. My proposal is to create a Cloud Function that checks for uniqueness before allowing the form to be submitted and providing more information and flexibility to the frontend. I think this will be the most prudent solution as writing these validations is rules requires workarounds, which we want to avoid. If you need help with this, I'll be happy to help you with the rules and the cloud function. |
Your help will be great :) Actually I've not had a good experience with Cloud Functions as sometimes it can take a while to load... perhaps I'm using it wrongly. |
By default, all Cloud Functions run in us-central1, which is in Iowa. You can change the region where your cloud functions run, which will reduce latency for your clients, take a look at this documentation. Personally, I use asia-east2 which is located in Hong Kong since it is the closest to Singapore. Also, there is a concept of a 'cold boot' time for Cloud Functions, which means that it'll take time for it to spin-up when it hasn't been used for a while, once it becomes 'warm', it gets significantly faster. |
Oh wow didn't know all those things, thanks so much! Added in the regions :) |
I'll help with writing the function for #58 and some validation rules for Firestore. For data validation, I'll try to validate fields that can be validated, as Firestore rules' syntax is not a full-fledged programming language (ideally, these tasks should be delegated to cloud functions, so you have more control), but I'll see what I can do. |
Thanks so much for agreeing to help!! :) that sounds greattt |
Just a quick update, I've written some rudimentary rules and unit tests for them, will make a PR when I'm done.
|
Thanks for the update :) Responses below
|
For 1), I think it's the same as 3, just try to streamline the document, (i.e. you can create folders in Firebase Storage, so you can name the folder such as to the document ID). Need to brainstorm about this. For 2), if you guys are considering adding authentication, you can have a look a Firebase authentication for very quick integration into your web app, you don't have to manage the storing of usernames/passwords, all you have to do is create a /Users/ collection to tracker other user information/access controls, if you need help with this, I will be glad to with the integration and on the backend as well. To be clear, it is very difficult to add security rules/validation to an open database, because there is no concept of ownership/identification, this makes it difficult to limit who can view/edit documents. This solves the problems of ownership/identification, but anyone with an account can create documents, but that's a problem for the validation side. We'll have to think of the best way to do this. |
Thanks so much! I've no prior experience with authentication so that'll be great :) I've created a Users collection in case you wish to further build on this. On a side note, I'll take a look at your PR and merge it! |
No worries! Always happy to help, when authentication comes in, you'll definitely need to use Cloud Functions to create user documents, and restrict any write access to them, since you do not want any User modifiable fields in there (for obvious security reasons). Anyway, if you have any questions about the PR let me know (sorry for the botched commit messages!). |
Currently, our Firestore security allows anyone to access it... we will appreciate help configuring firestore.rules to step up security but at the same time allow Github developers to run locally on their machine.
The text was updated successfully, but these errors were encountered: