Locking down a REST API to one app. How?

别来无恙 提交于 2020-03-25 17:11:34

问题


I have a small one page browser based app which consumes a REST API. Users are authenticated via a shortish lived token based system.

I'm likely going to expand this to also include mobile apps (either native or hybrid) which will also consume the same API.

I do have one concern though - how can I 'lock' my API so that only my apps can consume it?

In other words, how can I stop someone else building an app that uses my API?


回答1:


You need some sort of authentication, and if you're going to do authentication you'll need to make your REST API use HTTPS. Basic auth usually fits the bill nicely. Your apps will have credentials, but your human users will not. This will also allow you to give credentials to a customer, or somebody who wishes to use your API if you would like.



来源:https://stackoverflow.com/questions/22405501/locking-down-a-rest-api-to-one-app-how

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!