Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
feat: protect endpoints
Marc Seitz871316bb002d
diff --git a/lib/trigger/pdf-to-image-route.ts b/lib/trigger/pdf-to-image-route.tsindex 69b97b9a..d1036d79 100644--- a/lib/trigger/pdf-to-image-route.ts+++ b/lib/trigger/pdf-to-image-route.ts@@ -68,6 +68,7 @@ export const convertPdfToImageRoute = task({body: JSON.stringify({ url: signedUrl }),headers: {"Content-Type": "application/json",+ Authorization: `Bearer ${process.env.INTERNAL_API_KEY}`,},},);diff --git a/pages/api/links/download/dataroom-document.ts b/pages/api/links/download/dataroom-document.tsindex f37d85ed..1878ee8f 100644--- a/pages/api/links/download/dataroom-document.ts+++ b/pages/api/links/download/dataroom-document.ts@@ -188,6 +188,7 @@ export default async function handle(method: "POST",headers: {"Content-Type": "application/json",+ Authorization: `Bearer ${process.env.INTERNAL_API_KEY}`,},body: JSON.stringify({url: downloadUrl,diff --git a/pages/api/links/download/index.ts b/pages/api/links/download/index.tsindex 92d781c0..a04201cb 100644--- a/pages/api/links/download/index.ts+++ b/pages/api/links/download/index.ts@@ -122,6 +122,7 @@ export default async function handle(method: "POST",headers: {"Content-Type": "application/json",+ Authorization: `Bearer ${process.env.INTERNAL_API_KEY}`,},body: JSON.stringify({url: downloadUrl,diff --git a/pages/api/mupdf/annotate-document.ts b/pages/api/mupdf/annotate-document.tsindex 85cd583c..4c3caf03 100644--- a/pages/api/mupdf/annotate-document.ts+++ b/pages/api/mupdf/annotate-document.ts@@ -242,15 +242,15 @@ export default async (req: NextApiRequest, res: NextApiResponse) => {return;}- // // Extract the API Key from the Authorization header- // const authHeader = req.headers.authorization;- // const token = authHeader?.split(" ")[1]; // Assuming the format is "Bearer [token]"-- // // Check if the API Key matches- // if (token !== process.env.INTERNAL_API_KEY) {- // res.status(401).json({ message: "Unauthorized" });- // return;- // }+ // Extract the API Key from the Authorization header+ const authHeader = req.headers.authorization;+ const token = authHeader?.split(" ")[1]; // Assuming the format is "Bearer [token]"++ // Check if the API Key matches+ if (token !== process.env.INTERNAL_API_KEY) {+ res.status(401).json({ message: "Unauthorized" });+ return;+ }const { url, watermarkConfig, viewerData, numPages } = req.body as {url: string;diff --git a/pages/api/mupdf/get-pages.ts b/pages/api/mupdf/get-pages.tsindex 81e04f8d..ff38b583 100644--- a/pages/api/mupdf/get-pages.ts+++ b/pages/api/mupdf/get-pages.ts@@ -9,6 +9,16 @@ export default async (req: NextApiRequest, res: NextApiResponse) => {return;}+ // Extract the API Key from the Authorization header+ const authHeader = req.headers.authorization;+ const token = authHeader?.split(" ")[1]; // Assuming the format is "Bearer [token]"++ // Check if the API Key matches+ if (token !== process.env.INTERNAL_API_KEY) {+ res.status(401).json({ message: "Unauthorized" });+ return;+ }+try {const { url } = req.body as { url: string };// Fetch the PDF data