I have http://example.com/index.html
, which from within the HTML uses JavaScript (XmlHttpRequest) to call a web services at http://example.com/json/?a=...&b=...
The web service returns to index.html
a JSON array of information to then be displayed on index.html
.
Since anyone can view the source code for index.html
and see how I'm calling the JSON web service (http://example.com/json/
), how do I prevent people from calling my JSON web service directly?
Since the web service is essentially an open read into my database, I don't want people to abuse the web service and start fetching data directly from the web service, start DoS my server, fetching more information than they should, etc..
UPDATE:
Is there no way to limit requests for http://example.com/json/
to only come from the same server (IP) and URL request of http://example.com/index.html
?
Meaning, can't http://example.com/json/
detect that the Requester is ($_SERVER['REQUEST_URI'] == http://example.com/index.html
) and only allow that?