How To Secure Web Service Without Login

前端 未结 8 2574
终归单人心
终归单人心 2020-12-22 18:13

I have a mobile app (currently IOS and soon Android) which talks to a web service. There is no login and the data is not private. Basically, the app POSTs a marker (lon, lat

8条回答
  •  被撕碎了的回忆
    2020-12-22 18:57

    Actually in your particular case, since it is currently an iOS only app, there is a solution.

    1. After the user downloads and runs the app for the first time, the app hits a /access_token/create API that comes up with a GUID and relays it back to the Application via Apple's Push Notifications.

    2. App stores this access_token, and uses it on all subsequent requests. Your actual API's can rate limit on the basis of the access_token.

    Basically, you let Apple do all the hard work of ensuring that the initial request came from an actual iOS device.

    Extending this to Desktop clients is possible, but somewhat ruins the UX. Just change step 1 to allow /access_token/create to accept arbitrary requests, and if the request is not from a iOS device, then force the user to verify their email address/solve a captcha etc before issuing them an access_token.

    Android devices (not really familiar with them) may have a similar Push Notification mechanism, in which case you can use that, or may not have a Push Notification mechanism, in which case you can subject your Android users to the inconvenience listed above.

提交回复
热议问题