jsonwebtoken-auth-middleware
v1.0.8
Published
Creates Middleware for express by parsing JWT tokens using a public key
Downloads
2
Readme
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