I'm planning to create two projects.
One project will be a simple HTML/Javascript-centric project that uses AJAX to retrieve and poll data from a web service. Let's call it Project A.
The other project, Project B, is a RESTFul web service that simply caches data retrieve from external sources.
Basically Project B will serve as a web service to more than 1 more project. I will not be exposing Project B to the public. I just used Project A as an example project that will be polling from Project B.
I've read about OAuth 2.0 and it seems to be the best and most straight-forward way to prevent any other applications to access my web service. But here are some questions:
- Since Project A and Project B will be in two separate domains. Will AJAX work in this scenario? Because I've read that I have to work with JSONP if I'm planning to retrieve data from another domain. How secure is JSONP?
- Assuming I do implement OAuth, how will I manage my security keys for token encryption/decryption? Initially, what I was thinking was Project A to be a simple Java project which can basically store the secret keys and poll from my web service. That way, problem #1 can be resolved since I can just plainly use a simple AJAX function. But, I feel that it's quite unnecessary to make a Java web project just to store the keys and poll the information from the web service. My concern here is that, if I don't make it a Java project, I don't know where to store my keys. Surely, I won't store/expose it in the JS code.
Which leads me to ask, is OAuth 2.0 the right way to go? Or are there any other simpler alternatives?