phpiosobjective-chttp

Secure API so usage only available inside mobile application


I'm currently working on a mobile application with an Objective-C developer. Because of the nature of mobile devices and how they work, all data is retrieved through an API I have created.

For example, if the user is trying to find something specific to do with the application on a page (a search maybe), the application would make a request:

http://mydomain.example.com/api/search?param1=hello&param2=world

If these calls are made from the mobile device through the application I know they are legitimate requests (what I class as legit, anyway). If they're coming from somewhere else I really need to stop that. For example, another developer could copy the exact same application and use the API I have built on my server and there is no way I know of that can stop them doing that.

Is there a way I can secure the API some how to stop the API from being accessed outside the app?


Solution

  • Assuming there are no user accounts for authentication, the only way to secure the app is to hardcode a security token in the mobile app. And even doing so, it won't be 100% secure, because of reverse engineering.

    Your API only receive HTTP requests, so the only way to differenciate a legitimate with a non-legitimate request is to send a further information that will be considered as valid on your server side (as OAuth tokens), but if there are no user accounts, you will have to send an identical token shared by all apps (or following a commnon rule).

    I think that the best solution here is to hardcode the security token, it will at least force "hackers" to reverse engineer your app and not just sniffing the network.