securing a REST API accessible from Android

后端 未结 5 861
故里飘歌
故里飘歌 2020-12-07 10:37

We\'re building a game for Android, which needs access to web services - so we wrote a RESTful API in PHP that runs on our own server. What the API offers is: creating u

5条回答
  •  猫巷女王i
    2020-12-07 11:09

    You mentioned users faking the high scores. This could still happen if your users are authenticated. When the game is uploading the high scores you may want to have it also upload a proof of the score. For example Score 20100 from 103 bugs squished, 1200 miles flown, level 3 reached, and 2 cherries were eaten. This is by no means perfect but would cover the low hanging fruit.

    The first you should do is have authenticated users. Userid/password/session token etc., see if you can find some already existing frameworks. Once you have user authentication make sure you can do it securely with TLS or similar.

    As far as I know there is no way your server can be certain that the request is coming from your application (it's all just bits in packets) but you can at least make it hard for someone to be malicious.

    • Build a secret into your application (as suggested by other responses, key, hash salt etc.)
    • Generate a unique ID on the first execution of the application after installation and track that along with the logged in user. Details on this and the device's unique ID (why not to use it) can be found on the android blog
    • Some ideas discussed in this post How to ensure/determine that a post is coming from an specific application running on an iPhone/iTouch?
    • Check User Agent

提交回复
热议问题