CGUC / skybunk-server

The back-end application for Conrad Grebel University College students to stay connected
3 stars 9 forks source link

Make sensitive endpoints private #63

Closed aopal closed 5 years ago

aopal commented 6 years ago

Some endpoints are completely public, but expose private information. e.g. some people have put their full addresses on their bio, which is public via the /users endpoint.

These endpoints should be only accessible when requested with a valid token. We may want to make all endpoints require tokens, other than those related to registration.

pii

picklechips commented 5 years ago

Just copying my comment from a PR here in case anyone decides to pick this up.

to make an endpoint protected all you have to do is add the verifyToken parameter as used here: https://github.com/CGUC/skybunk-server/blob/master/controllers/userController.js#L56

Then when sending a request at that endpoint you just have to include the users auth token. So in order to make our public endpoints only accessible to registered users, we'd first have to update the calls on the client-side to include the users token (also trivial) as to not break everything, then we can simply add verifyToken into the parameters of the endpoint.

What this does is adds a middleware onto that endpoint, so before entering it we first execute verifyToken as defined here: https://github.com/CGUC/skybunk-server/blob/master/helpers/authorization.js which checks for the users token and sends a 403 otherwise.