Created
October 24, 2019 22:17
-
-
Save gdestuynder/f3a73d2a465d8b05c81e954ffeafc762 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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