1.0.8 • Published 5 years ago

jsonwebtoken-auth-middleware v1.0.8

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

jsonwebtoken-auth-middleware

Creates Middleware for express by parsing JWT tokens using a public key

//Setup
const app = express();
//replace certs.publicCert with a string that is your public cert
const middleware = authMiddleware(certs.publicCert);

app.use(middleware);

//Use in endpoint
app.get('/test', (req, res) => {
  //req.jwt will contain the object values embedded in the jwt token
  res.send(req.jwt);
});

//Calling in to the endpoint - assuming it's hosted at localhost:3000
curl -H "Authorization: Bearer <JWT_TOKEN>" http://localhost:3000/test