ed209
ed209

Reputation: 11303

Can I use IP addresses to limit API access

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?

Upvotes: 3

Views: 1212

Answers (3)

Trevor
Trevor

Reputation: 60260

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.

Upvotes: 1

Ben S
Ben S

Reputation: 69412

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.

Upvotes: 2

Femaref
Femaref

Reputation: 61497

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.

Upvotes: 1

Related Questions