-
Notifications
You must be signed in to change notification settings - Fork 33
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
whitelist query parameters (instead of passing client's object) #7
Comments
This looks great but honestly I didn't fully understand the benefits of this (please consider that I've stated with meteor two months ago :P). Are you considering possible security problems? Thanks a lot! |
Yes, security. It's to consider that the query object comes from the client. Someone may be trying to send a query to access information that should not be accessible to him. Thus, publish function have to check client input, and make sure it is only used in a save way. |
With |
I've been working in a first approach about security. I've added a new method "allow" for the publisher that will let developers do some custom validation before any publisher run anything. The approach is at https://github.com/julianmontagna/filter-collections/tree/0.1.2 (with updated README.md) If you are available, let me know your thoughts. |
I see, the "allow" is usefull for example to block all access for non-admin users etc. To return only specified whitelisting fields, it may be possible to take a list of whitelisted fields and add those fields to the The other part would be to restrict the maximal possible "scope" (#9 (comment)) for the user. Maybe by defining a minimal set of query selectors that are always added? Overall, maybe there is a more universal way out of this, that may also make c-f more flexible to use, if the approach could be turned around. Rather than adding special parameters to make c-f more flexible (but harder and peculiar to configure), maybe c-f features could be added to custom publish() functions (#10). Maybe by adding some c-f supplied sort, filter, skip, limit objects? |
Yes, 'allow' will be 'deny' and is not 'fields'. I've pushed that since I needed on the project that I'm working for as a first approach of "security"? :P Getting back to 'fields:' topic, I'm asking myself if a possible implementation could be:
and/or support also something like:
Then, the publisher will attach this to the query before building the cursor (.find) and this way we should have a way to restrict the document fields sent back to the client. Also, if no 'fields:' value was configured, all fields will be sent. That's sounds good to you? Please, let me know your thoughts. |
In js I am really a bloody newby. Still, that api would look quite flexible to me. :) When "attaching" the field dictionary from the client, just make sure only whitelisted fields are added (those also present in the whitelist). The docs left me in the impession that a |
The publish function should only publish on a whitelist basis.
Instead of executing client supplied finds:
Only _.pick out whitelisted
field:
parameters,and use the other parts only as explicit sort and limit objects in the find:
The text was updated successfully, but these errors were encountered: