0

I have been trying to wrap my brain around authentication on an API I am to develop.

I've tried to think of a way to successfully authenticate users, keeping in mind that users can access all data on the client, and I've come up with this idea.

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

Is this a secure way to do it, or do you see any security flaws?

Pixark
  • 385
  • 1
  • 4
  • 13

1 Answers1

0

First, Do i see security flaws? Yes and No. If you are not using a secure connection, sending a users password and username through the net would not be a good idea. Especially if you have not Hashed the User's password in sha512 or whatever you use.

I would hash the password on the client Side, then send it.

Take a look at Twitter's API for example. They use the Keys to authenticate your account as well.

Here is a useful article.

Hunter Mitchell
  • 7,063
  • 18
  • 69
  • 116