Skip to content

Relying only in Parse Cloud Code #3067

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

Closed
RafaRuiz opened this issue Nov 17, 2016 · 19 comments
Closed

Relying only in Parse Cloud Code #3067

RafaRuiz opened this issue Nov 17, 2016 · 19 comments

Comments

@RafaRuiz
Copy link

Hello guys.

This is a question I've tried to find anywhere in StackOverflow or here but I haven't found.
Some of us, developers who use Parse for a backend solution, rely only on Parse Cloud Code to make requests. Sometimes we develop X-platform products which is really nice, but maybe we would like to avoid people to fiddle with the REST part (or from Javascript SDK for example). Is there any plan to be able to cut everything except some endpoints such as "http://parsehost/parse/functions/*" for the future?

Thank you very much in advance, and I'm sorry if this question is duplicated (I haven't found it).
Regards.

@flovilmart
Copy link
Contributor

You can build an express app with a simple API if that's what you need.

@RafaRuiz
Copy link
Author

@flovilmart thank you for your answer... is there any reference I can read or any idea?
Thank you again

@flovilmart
Copy link
Contributor

What you want is actually just a web server, that is using parse as a backend right? you can use expressjs http://expressjs.com and then make an API client on your apps.

@RafaRuiz
Copy link
Author

No, well, I would like to use Parse directly, but disabling Queries from clients of cURL. I use background jobs, push, and many more Parse features. What I want actually is being protected against calls like http://mywebserver:1337/parse/users and read every single field. I'm getting sensitive data (according to my structure) but I need Users to be public readable.

In Parse Cloud I use .select to retrieve the right fields.
I don't know if I explained well, is it clear?

@flovilmart
Copy link
Contributor

You can use beforeFind calls to transform you query before it's executed. If you want to disable full endpoints you can also do

app.get('/parse/users', function(req, res) {
   res.send(404, 'Not found')
})
app.use('/parse', parseAPI)

@RafaRuiz
Copy link
Author

@flovilmart that is gorgeous... thank you very much!

@RafaRuiz
Copy link
Author

@flovilmart, I've been checking deeply, it wouldn't work to isolate only Parse Cloud for example.

I tried to isolate in this way:

app.all('/parse/*', function(req, res, next) {
   if (!req.url.startsWith("/parse/functions")) {
      res.send(404, 'Not found');
   } else {
      next();
   }
});

but Parse Cloud is using /parse/classes/_User for retrieving users, for example, and it wont work... do you have any other workaround or idea to work with? I'm still thinking but got no clue :(

@flovilmart
Copy link
Contributor

Yeah because you need all of those still working because parse-server is well, parse-server... I'm not sure we're gonna go that route...

@RafaRuiz
Copy link
Author

So what would you suggest for this?

"I have done a search on Google saying ' websites done with parse as backend '. I got one, I opened the Javascript console (or well, grab the REST-Api-Key from any cloud call and do the same job with cURL) and this happened:"

image

What could we do in this case?

@flovilmart
Copy link
Contributor

put a CLP so you can't run a find...

@RafaRuiz
Copy link
Author

so I can't run a find from Parse Cloud either :\ ?

@flovilmart
Copy link
Contributor

you can run find with the master key

@RafaRuiz
Copy link
Author

alright! let's try :)
thanks!

@steven-supersolid
Copy link
Contributor

We do something similar to the suggestion: All classes have no read and write access via CLP (make sure to switch to advanced permissions mode to also unset Add Field) and our cloud code queries etc. all have useMasterKey: true

Perhaps it would be useful to have a special mode so it is like this out of the box but it is low priority for me as you can achieve this already using the above steps.

@cleever
Copy link

cleever commented Nov 18, 2016

I've tried to change CLP for User object, disabling Public GET and FIND.
But new users are unable to Signup without Public GET. Login works fine. (Javascript SDK)

@kulshekhar
Copy link
Contributor

@cleever I had faced this issue and got around it by creating a cloud function to sign users up

@jonas-db
Copy link

jonas-db commented Nov 18, 2016

I think you need an ACL in this case. Whenever a user signs up, you should place an ACL on that user. This should avoid public queries to find this user.

@kyvu
Copy link

kyvu commented Nov 18, 2016

@steven-supersolid I'm using the same thing as you where I disable access to all the tables and only use Cloud Code to access. I'm migrating off to Parse Server now and update all Cloud Code to use master key explicitly and removing the current user call but the queries don't return any data now. Seems like the useMasterKey is not working for some reason and I have been banging my head against the wall for the past 2 days. Is yours working?

@flovilmart any help or suggestion here? I google and read all the issue and it seems like it should be working but it's not for me. I using Heroku and mLab and running the latest version of Node 6.9.1 and the latest beta version of Parse Server.

Any help or direction would be greatly appreciated.

@steven-supersolid
Copy link
Contributor

@kyvu probably best to ask on SO and provide a simple code sample and server logs as seems like an issue with your setup

@hramos hramos closed this as completed Nov 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants