Get config variables in auth0 in env file

This commit is contained in:
2021-10-04 09:59:29 -05:00
parent 737be09b5f
commit cc44c409d7
10 changed files with 58 additions and 76 deletions

19
api/middleware/secure.js Normal file
View File

@@ -0,0 +1,19 @@
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.SNOWPACK_PUBLIC_AUTH0_DOMAIN}/.well-known/jwks.json`,
}),
// Validate the audience and the issuer
audience: `https://${process.env.SNOWPACK_PUBLIC_API_DOMAIN}/`, //replace with your API's audience, available at Dashboard > APIs
issuer: `https://${process.env.SNOWPACK_PUBLIC_AUTH0_DOMAIN}/`,
algorithms: ["RS256"],
});
module.exports = secure;