Reputation: 1100
I'm sorry to put another REST Authenticate question on the website but I really need to get a complete answer. I have a REST API in which I try to log in a single page website (through jquery).
I want to create a token based authentication, but there is some step I still can't understand.
At first, do I have to make a normal authentication to get and store in db the user login/password ? Do I have to use the user session to store the token ? Does someone have an exemple of php code that I can use ?
source :
----------- EDIT ---------------
Ok, I have some news to add.
Upvotes: 3
Views: 2371
Reputation: 1100
Oh, I just see the badge "no view and no answer for a long time" and it bring me back here. I've finally found the answer :
The register is something you do only one time so you can send the hash key without a really good protection. (I mean against sniffing).
So here is the scenario to register :
Now for the login
Now Everytime the client want to make a authenticate request, he will use the following method :
The Server receive the request (login, timestamp, params, hash_request), check if the timestamp is not too old and do the generate the hash_request from the token in hashmap for the login and check if it the same. In this way, you avoid the replay (timestamp) and the clear password.
Upvotes: 4