Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nodejs Restful Auth

I'm new with Nodejs and I'm doing a restful server with restify. So, I have a scenario that I have many devices (with unique id) updating data through rest. What I want to do is authenticate them and give a auth token. Something like this:

First time: uri/api/auth -> get Token.

Then: uri/api/product/.... -> with token and updating product

I tried to use restify-node-token but I have no success.

like image 217
Poliane Brito Avatar asked Oct 10 '12 13:10

Poliane Brito


1 Answers

JWT is an authentication method very extended and easy to use, there are many of libraries that implement it. It has several advantages, like the token has user information encrypted in it, so you don't need to access to the DB with each request to authenticate the user. You can take a look to the code example here https://solidgeargroup.com/refresh-token-autenticacion-jwt-implementacion-nodejs?lang=es It also implements a refresh token to generate new tokens when they expire.

like image 66
David Vicente Avatar answered Oct 11 '22 23:10

David Vicente