Skip to content

Instantly share code, notes, and snippets.

@gdestuynder
Created October 24, 2019 22:17
Show Gist options
  • Save gdestuynder/f3a73d2a465d8b05c81e954ffeafc762 to your computer and use it in GitHub Desktop.
Save gdestuynder/f3a73d2a465d8b05c81e954ffeafc762 to your computer and use it in GitHub Desktop.
var express = require('express');
var app = express();
var jwt = require('express-jwt');
var jwks = require('jwks-rsa');
var port = process.env.PORT || 8080;
var jwtCheck = jwt({
secret: jwks.expressJwtSecret({
cache: true,
rateLimit: true,
jwksRequestsPerMinute: 5,
jwksUri: 'https://auth.mozilla.auth0.com/.well-known/jwks.json'
}),
audience: 'api.sso.mozilla.com',
issuer: 'https://auth.mozilla.auth0.com/',
algorithms: ['RS256']
});
app.use(jwtCheck);
app.get('/authorized', function (req, res) {
res.send('Secured Resource');
});
app.listen(port);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment