Simple, secure API authentication system

前端 未结 5 580
梦谈多话
梦谈多话 2021-01-30 02:27

I have a simple REST JSON API for other websites/apps to access some of my website\'s database (through a PHP gateway). Basically the service works like this: call example.com/f

5条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-30 03:11

    If someone's client side code is compromised, they should get a new key. There's not much you can do if their code is exposed.

    You can however, be more strict by requiring IP addresses of authorized servers to be registered in your system for the given key. This adds an extra step and may be overkill.

    I'm not sure what you mean by using a "simple API key" but you should be using some kind of authentication that has private keys(known only to client and server), and then perform some kind of checksum algorithm on the data to ensure that the client is indeed who you think it is, and that the data has not been modified in transit. Amazon AWS is a great example of how to do this.

    I think it may be a little strict to guarantee that code has not been compromised on your clients' side. I think it is reasonable to place responsibility on your clients for the security of their own data. Of course this assumes that an attacker can only mess up that client's account.

    Perhaps you could keep a log of what ip requests are coming from for a particular account, and if a new ip comes along, flag the account, send an email to the client, and ask them to authorize that ip. I don't know maybe something like that could work.

提交回复
热议问题