Unfortunately, your webservice will never be completely secure but here are few of the basic things you can do:
- Use SSL
- Wrap all your (app) outbound payloads in
POST
requests. This will prevent casual snooping to find out how your webservice works (in order to reverse engineer the protocol).
- Somehow validate your app's users. Ideally this will involve OAUTH for example using Google credentials, but you get the idea.
Now I'm going to point out why this won't be completely secure:
- If someone gets a hold of your app and reverse engineers it, everything you just did is out the window. The only thing that will hold is your user validation.
- Embedding a client certificate (as other people have pointed out) does nothing to help you in this scenario. If I just reverse enginneered your app, I also have your client certificate.
What can you do?
- Validate the accounts on your backend and monitor them for anomalous usage.
Of course this all goes out the window when someone comes along, reverse engineers your app, builds another one to mimic it, and you wouldn't (generally) know any better. These are all just points to keep in mind.
Edit: Also, if it wasn't already obvious, use POST
(or GET
) requests for all app queries (to your server). This, combined with the SSL should thwart your casual snoopers.
Edit2: Seems as if I'm wrong re: POST
being more secure than GET
. This answer was quite useful in pointing that out. So I suppose you can use GET
or POST
interchangeably here.