Nodejs Restful Auth
Asked Answered
F

2

6

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.

Frecklefaced answered 10/10, 2012 at 13:53 Comment(2)
Are you using expressjs ?Warmonger
If so, you can try using express-jwt package by auth0 to issue & validate json web tokens. Pls find the link here : github.com/auth0/express-jwtWarmonger
T
2

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.

Thoracoplasty answered 18/7, 2017 at 6:50 Comment(0)
D
0

http://passportjs.org/

This is a library for express.js, but I've very powerful. I'd suggest you'd give it a look. Setting up what you have already with express.js would take very little work.

Denumerable answered 23/1, 2013 at 17:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.