express-jwt-verify
v1.0.1
Published
middleware for express that verifies jwt token
Downloads
4
Readme
express-jwt-verify
JSON Web Token middleware for expressJS that verifies that the token is valid.
This is mainly a school assignment at Blekinge Institute of Technology.
Install
npm install express-jwt-verify --save
Usage
var jwtMiddleware = require('express-jwt-verify');
var protectedRoutes = express.Router();
app.use('/protected', protectedRoutes);
protectedRoutes.use(jwtMiddleware('mysecret'));
protectedRoutes.get('/decoded', function(req, res) {
res.json(req.decoded);
});
If the verification succeeds it will the pass decoded token with the request (req.decoded) and if it fails it sends a HTTP 403 status and a JSON-body with information.
Theese options can be passed to the verify function:
https://github.com/auth0/node-jsonwebtoken#jwtverifytoken-secretorpublickey-options-callback
var jwtMiddleware = require('express-jwt-verify');
protectedRoutes.use(jwtMiddleware('mysecret' , { maxAge: 1000 }));