This repository has been archived on 2022-10-07. You can view files and clone it, but cannot push or open issues or pull requests.
2021-02-03 14:06:44 +00:00
|
|
|
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
|
|
|
|
|
2021-02-04 13:31:26 +00:00
|
|
|
import jwt from "express-jwt";
|
|
|
|
import jwks from "jwks-rsa";
|
|
|
|
import config from "../../src/config";
|
|
|
|
|
|
|
|
// This middleware assumes that the app is secured using ORY Oathkeeper, in which case we
|
|
|
|
// verify the JSON Web Token issued by ORY Oathkeeper using the jwt-express middleware.
|
|
|
|
|
|
|
|
const middleware = jwt({
|
|
|
|
// Dynamically provide a signing key based on the kid in the header and the signing keys provided by the JWKS endpoint.
|
|
|
|
secret: jwks.expressJwtSecret({
|
|
|
|
cache: true,
|
|
|
|
jwksRequestsPerMinute: 5,
|
|
|
|
jwksUri: config.jwksUrl,
|
|
|
|
}),
|
|
|
|
algorithms: ["RS256"],
|
|
|
|
});
|
|
|
|
|
|
|
|
export default middleware((req, res) => {
|
|
|
|
console.log(Object.keys(req));
|
|
|
|
console.log(req);
|
|
|
|
console.log(JSON.stringify(req));
|
2021-02-03 14:06:44 +00:00
|
|
|
res.statusCode = 200;
|
|
|
|
res.json({ name: "John Doe" });
|
2021-02-04 13:31:26 +00:00
|
|
|
});
|