Web API身份验证

时间:2013-11-10 17:25:30

标签: php mysql api authentication

我一直试图将我的大脑围绕着我要开发的API进行身份验证。

我试图想出一种成功验证用户身份的方法,记住用户可以访问客户端上的所有数据,我想出了这个想法。

Client sends username and password to the server
Server checks if they match a user.
    If it does, we create a hashed string with user_id+e-mail+currentTime+salt
    and stores this in a database-table with an expiration date.
Server returns hashed string to client

Client sends random request to server including key
Server checks if key is correct and if it's expired

这是一种安全的方法吗,或者您是否看到任何安全漏洞?

1 个答案:

答案 0 :(得分:0)

首先,Do i see security flaws?是和否。如果您没有使用安全连接,通过网络发送用户密码和用户名不是一个好主意。特别是如果你没有使用sha512中的用户密码或任何你使用的密码。

我会在客户端哈希密码,然后发送它。

以Twitter的API为例。他们也使用密钥对您的帐户进行身份验证。

这是一个有用的article