Files
forgetmenot-serverless/api/middleware/secure.js
2021-10-04 17:18:55 -05:00

20 lines
652 B
JavaScript

const jwt = require("express-jwt");
const jwksRsa = require("jwks-rsa");
const secure = jwt({
// Dynamically provide a signing key based on the kid in the header and the signing keys provided by the JWKS endpoint
secret: jwksRsa.expressJwtSecret({
cache: true,
rateLimit: true,
jwksRequestsPerMinute: 5,
jwksUri: `https://${process.env.auth0Domain}/.well-known/jwks.json`,
}),
// Validate the audience and the issuer
audience: process.env.auth0Audience, //replace with your API's audience, available at Dashboard > APIs
issuer: `https://${process.env.auth0Domain}/`,
algorithms: ["RS256"],
});
module.exports = secure;