restify-jwt-auth-next

1.1.0 • Public • Published

restify-jwt-auth-next

Lightweight JWT middleware for restify.

build status Coverage Status npm

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

Robert Jefe Lindstaedt

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i restify-jwt-auth-next

Weekly Downloads

0

Version

1.1.0

License

MIT

Last publish

Collaborators

  • eljefederodeodeljefe