From 9cd8aa9d270b34f9dd4069c7f289902e73ae97ec Mon Sep 17 00:00:00 2001 From: Marcos Candeia Date: Tue, 6 Feb 2024 15:23:55 -0300 Subject: [PATCH] Add logs (#31) Signed-off-by: Marcos Candeia --- api/auth.ts | 2 ++ api/router.ts | 3 +++ 2 files changed, 5 insertions(+) diff --git a/api/auth.ts b/api/auth.ts index d211383..8ac5af0 100644 --- a/api/auth.ts +++ b/api/auth.ts @@ -102,6 +102,7 @@ export const withAuth = (): MiddlewareHandler< if ( !isAllowed(namespace, payload) ) { + console.warn(`${credentials} is invalid`); const res = new Response("Forbbiden", { status: 403, headers: { @@ -121,6 +122,7 @@ export const withAuth = (): MiddlewareHandler< url.search = ""; const atLeastOneIsAllowed = scopes.some((scope) => scope.test(url)); if (!atLeastOneIsAllowed) { + console.warn(`${credentials} scope not allowed.`); const res = new Response("Forbbiden", { status: 403, headers: { diff --git a/api/router.ts b/api/router.ts index 28213a7..88c9159 100644 --- a/api/router.ts +++ b/api/router.ts @@ -47,6 +47,7 @@ export const getRouter = async ( const { id } = req.param(); const execution = await service.getExecution(id); if (execution === undefined) { + console.error("execution not found", id); return Response.json({}, { status: 403 }); // do not expose not found errors. } return Response.json(execution); @@ -55,6 +56,7 @@ export const getRouter = async ( const { id } = req.param(); const execution = await service.getExecution(id); if (execution === undefined) { + console.error("execution not found", id); return Response.json({}, { status: 403 }); // do not expose not found errors. } await service.touchExecution(id); @@ -75,6 +77,7 @@ export const getRouter = async ( pageSize ? +pageSize : 10, ); if (history === undefined) { + console.error("execution not found", id); return Response.json({}, { status: 403 }); // do not expose not found errors. } return Response.json(history);