Search code examples
phpandroidjsonrestrict

Restricting access to php file


I'm currently writing an Android app at the moment, that accesses a PHP file on my server and displays JSON data provided by my MYSQL database.

Everything works great and I love the simplicity of it, but I'm not too comfortable with the fact that someone could just type in the URL of this PHP file and be presented with a page full of potentially sensitive data.

What advice would you give me to prevent access to this PHP file from anyone except those using my android app?

Thanks very much for any information.


Solution

  • The keyword is authentication. HTTP-Authentication is designed just for that purpose!

    There are 2 forms of HTTP-auth:

    1. Basic: easy to setup, less secure
    2. Digest: harder to setup, more secure

      • Here is the php manual.
      • And this is what you can do in your android app.