@@ -10,9 +10,11 @@ import {
1010 BenchmarkWizardStepResponse ,
1111 CreateBenchmarkRequest ,
1212 ListBenchmarksResponse ,
13+ Permission ,
1314 PrincipalType ,
1415} from '@openops/shared' ;
1516import { StatusCodes } from 'http-status-codes' ;
17+ import { getProjectScopedRoutePolicy } from '../core/security/route-policies/route-security-policy-factory' ;
1618import { assertBenchmarkFeatureEnabled } from './benchmark-feature-guard' ;
1719import { getBenchmarkStatus , listBenchmarks } from './benchmark-status.service' ;
1820import { createBenchmark } from './create-benchmark.service' ;
@@ -47,14 +49,17 @@ export const benchmarkController: FastifyPluginAsyncTypebox = async (app) => {
4749 userId : request . principal . id ,
4850 benchmarkConfiguration : request . body . benchmarkConfiguration ,
4951 } ) ;
52+
5053 return reply . status ( StatusCodes . CREATED ) . send ( result ) ;
5154 } ,
5255 ) ;
56+
5357 app . get ( '/' , ListBenchmarksRequestOptions , async ( request , reply ) => {
5458 const items = await listBenchmarks ( {
5559 projectId : request . principal . projectId ,
5660 provider : request . query . provider ,
5761 } ) ;
62+
5863 return reply . status ( StatusCodes . OK ) . send ( items ) ;
5964 } ) ;
6065
@@ -74,6 +79,10 @@ export const benchmarkController: FastifyPluginAsyncTypebox = async (app) => {
7479const ListBenchmarksRequestOptions = {
7580 config : {
7681 allowedPrincipals : [ PrincipalType . USER ] ,
82+ security : getProjectScopedRoutePolicy ( {
83+ allowedPrincipals : [ PrincipalType . USER ] ,
84+ permission : Permission . READ_RUN ,
85+ } ) ,
7786 } ,
7887 schema : {
7988 tags : [ 'benchmarks' ] ,
@@ -91,6 +100,16 @@ const ListBenchmarksRequestOptions = {
91100const WizardStepRequestOptions = {
92101 config : {
93102 allowedPrincipals : [ PrincipalType . USER ] ,
103+ security : getProjectScopedRoutePolicy ( {
104+ allowedPrincipals : [ PrincipalType . USER ] ,
105+ permission : [
106+ Permission . READ_APP_CONNECTION ,
107+ Permission . UPDATE_FLOW_STATUS ,
108+ Permission . WRITE_FOLDER ,
109+ Permission . DELETE_FLOW ,
110+ Permission . WRITE_FLOW ,
111+ ] ,
112+ } ) ,
94113 } ,
95114 schema : {
96115 tags : [ 'benchmarks' ] ,
@@ -109,6 +128,16 @@ const WizardStepRequestOptions = {
109128const CreateBenchmarkRequestOptions = {
110129 config : {
111130 allowedPrincipals : [ PrincipalType . USER ] ,
131+ security : getProjectScopedRoutePolicy ( {
132+ allowedPrincipals : [ PrincipalType . USER ] ,
133+ permission : [
134+ Permission . READ_APP_CONNECTION ,
135+ Permission . UPDATE_FLOW_STATUS ,
136+ Permission . WRITE_FOLDER ,
137+ Permission . DELETE_FLOW ,
138+ Permission . WRITE_FLOW ,
139+ ] ,
140+ } ) ,
112141 } ,
113142 schema : {
114143 tags : [ 'benchmarks' ] ,
@@ -127,6 +156,10 @@ const CreateBenchmarkRequestOptions = {
127156const BenchmarkStatusRequestOptions = {
128157 config : {
129158 allowedPrincipals : [ PrincipalType . USER ] ,
159+ security : getProjectScopedRoutePolicy ( {
160+ allowedPrincipals : [ PrincipalType . USER ] ,
161+ permission : Permission . READ_RUN ,
162+ } ) ,
130163 } ,
131164 schema : {
132165 tags : [ 'benchmarks' ] ,
0 commit comments