Skip to content

eljefedelrodeodeljefe/restify-jwt-auth-next

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Lightweight JWT middleware for restify.

Resources

License

Stars

Watchers

Forks

Packages

No packages published