tags:

views:

38

answers:

3

I have a mini API that is only for an app I have built. The API service is on a separate domain to my app. I make jsonp calls to it and receive json in return.

Therefore I only want my app to be able to access it. Can I just list a series of IP addresses for my app and allow them? Is there a better way to stop requests from anyone else to my API?

+1  A: 

If the IP stays the same throughout time, yes this is a valid idea. Another way would be with an id and a key, if you expect further usage from other (dynamic) ip adresses.

Femaref
+1  A: 

The best way to implement IP-based filtering would be at the web-server level. Here's a brief introduction to access control with Apache. If that happens to be your web-server.

Ben S
+1  A: 

What operating system is the API service running on? If it's Linux, look into iptables to only allow a certain IP to access a specific port.

Trevor