From f802061722a1d624692403ac99bdd2fe788de4f7 Mon Sep 17 00:00:00 2001 From: Ali BARIN Date: Fri, 23 Jun 2023 20:57:08 +0000 Subject: [PATCH] feat(authorization): add read execution checks --- packages/backend/src/graphql/queries/get-execution-steps.ts | 2 ++ packages/backend/src/graphql/queries/get-execution.ts | 2 ++ packages/backend/src/graphql/queries/get-executions.ts | 2 ++ 3 files changed, 6 insertions(+) diff --git a/packages/backend/src/graphql/queries/get-execution-steps.ts b/packages/backend/src/graphql/queries/get-execution-steps.ts index 8267dbd7..01394dbe 100644 --- a/packages/backend/src/graphql/queries/get-execution-steps.ts +++ b/packages/backend/src/graphql/queries/get-execution-steps.ts @@ -12,6 +12,8 @@ const getExecutionSteps = async ( params: Params, context: Context ) => { + context.currentUser.can('read', 'Execution'); + const execution = await context.currentUser .$relatedQuery('executions') .withSoftDeleted() diff --git a/packages/backend/src/graphql/queries/get-execution.ts b/packages/backend/src/graphql/queries/get-execution.ts index 550385bc..19ff929e 100644 --- a/packages/backend/src/graphql/queries/get-execution.ts +++ b/packages/backend/src/graphql/queries/get-execution.ts @@ -9,6 +9,8 @@ const getExecution = async ( params: Params, context: Context ) => { + context.currentUser.can('read', 'Execution'); + const execution = await context.currentUser .$relatedQuery('executions') .withGraphFetched({ diff --git a/packages/backend/src/graphql/queries/get-executions.ts b/packages/backend/src/graphql/queries/get-executions.ts index ee261f1b..90d96517 100644 --- a/packages/backend/src/graphql/queries/get-executions.ts +++ b/packages/backend/src/graphql/queries/get-executions.ts @@ -12,6 +12,8 @@ const getExecutions = async ( params: Params, context: Context ) => { + context.currentUser.can('read', 'Execution'); + const selectStatusStatement = ` case when count(*) filter (where execution_steps.status = 'failure') > 0