In Detail here's the problem:
I'm building an Android app, which consumes my REST API on the back-end. I need to build a Registration and Login API to begin with. After googling for a while, I feel like there are only two approaches that i can take.
- During Registration, I use https and get the user's credentials; save it in my DB against the username(server side). During Login, again I use https, and ask the user's credentials; verify the hashed password on the DB and return him a session ID, which i'm planning to never expire; unless he Log's Out. Further any other api calls(GET/POST) that the user makes, will be accompanied with this session ID so that I can verify the user.
But in the above approach I'm forced to use https for any api call, else I'm vulnerable to Man in The Middle Attack, i.e. if anyone sniffs over my session ID, he can reconstruct similar GET/POST requests which i wouldn't want. Am i right with the above assumption ?
- The second option is to follow the path of Amazon Web Services, where i use public/prvate key authentication. When a user registers i use a https api to save his/her credentials in the DB. From then on I use the user's hashed password as the private key. Any further api calls that the user makes will be having a hashed blob of the request url using the user's private key. On the server side I reconstruct the hash using the saved private key. If the hash is a match I let the user do his task, else reject. In this option i need to use https only for the registration API. The REST can go on on http.
But here the disadvantage is, that I'm forced to host my Registration API in a separate Virtual Directory(I'm using IIS and i'm not sure if i can host both http and https APIs in the same Virtual Directory). Hence I'm forced to developing the Registration API in a separate project file. Again Am I right with the above assumption ?
Edit: I'm using ASP.NET MVC4 to build the web API
The reason I'm reluctant to use https for all of my REST API calls is that I feel it's not light weight and creates more network payload, which may not be best suited for a moble App. Further encryption/decryption and extra handshake required may further affect a Mobiles battery Life ?? Or is it not significant ?
Which of the above two approaches would you suggest ?