Skip to content

Commit

Permalink
Add logs (#31)
Browse files Browse the repository at this point in the history
Signed-off-by: Marcos Candeia <[email protected]>
  • Loading branch information
mcandeia authored Feb 6, 2024
1 parent 6f8cd0f commit 9cd8aa9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions api/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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: {
Expand Down
3 changes: 3 additions & 0 deletions api/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 9cd8aa9

Please sign in to comment.