1.1.0 • Published 8 years ago

restify-jwt-auth-next v1.1.0

Weekly downloads
4
License
MIT
Repository
github
Last release
8 years ago

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

1.1.0

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago