restify-jwt-auth-next
v1.1.0
Published
Lightweight JWT middleware for restify.
Downloads
3
Readme
restify-jwt-auth-next
Lightweight JWT middleware for restify.
Installation
npm install --save restify-jwt-auth-next
Usage
const restify = require('restify')
const jwtAuth = require('restify-jwt-auth-next')
var restify = restify.createServer({})
let handler = function (req, res, next) {
return res.redirect('/login', next)
}
let options = {
secret: 'jwtsecret',
blacklist: [], // blacklist routes like '/noaccess', will always return handler
whitelist: [], // whitelist routes like '/immediate', no auth needed
handler: handler // default is redirect as above. Will send a 302 and the login route
}
server.use(jwtAuth(options))
// protected route
server.get('/jwttest', function (req, res, next) {
let testObj = {testObj: 'testObj'}
return res.json(testObj)
})
server.listen(3000, 'localhost', function () {
})
Credits
License
MIT