H
H
HoHsi2015-10-08 08:20:22
Node.js
HoHsi, 2015-10-08 08:20:22

What is the best way to authenticate a user?

What is the best way to authenticate a user and what methods are best to use to build a Cookie token? What is this cookie to build from?
How good are the following options:
* Adding salt to cookies, which is also written to the database and generated during authorization.
* Binding cookies to the user's IP, which is also written to the database.
* Cookies as a concatenation of "login + separator + password hash"
* Generate a random token and write it to the database

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex Kheben, 2015-10-08
@zBit

There are ready-made solutions for authorization: Passport , for example.
And how are you going to bind the cookie to the user's IP address? Use JWT and you will be happy, you don’t need to think about such trifles with it.
And what about cookies in general?) Cookie is just one of the options to store the user session ID, you can use LocalStorage for this if your content is not rendered on a server, but for example, you use Web API + Client (Angular, Knockout, ReactJS, native app or whatever)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question