Skip to content

Instantly share code, notes, and snippets.

@simonr-cb
Created January 12, 2018 16:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simonr-cb/65d35e6495c7ba170406bf69390357d3 to your computer and use it in GitHub Desktop.
Save simonr-cb/65d35e6495c7ba170406bf69390357d3 to your computer and use it in GitHub Desktop.
// Create middleware for checking the JWT
const checkJwt = jwt({
// Dynamically provide a signing key based on the kid in the header and the singing keys provided by the JWKS endpoint
secret: jwksRsa.expressJwtSecret({
cache: true,
rateLimit: true,
jwksRequestsPerMinute: 5,
jwksUri: "https://" + config.auth0Domain + "/.well-known/jwks.json"
}),
// Validate the audience and the issuer.
audience: process.env.AUTH0_AUDIENCE,
issuer: "https://" + config.auth0Domain + "/",
algorithms: ['RS256']
})
router.use(checkJwt)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment