@@ -21,8 +21,9 @@ import {
2121} from '@nestjs/swagger' ;
2222import { ApiBearerAuth } from '@nestjs/swagger' ;
2323import { GetAppDTO } from './apps.dto' ;
24- import { OKDTO } from '../shared /dto/ok.dto' ;
24+ import { OKDTO } from '../common /dto/ok.dto' ;
2525import { JwtAuthGuard } from '../auth/strategies/jwt.guard' ;
26+ import { ReadonlyGuard } from '../common/guards/readonly.guard' ;
2627
2728@Controller ( { path : 'api/apps' , version : '1' } )
2829export class AppsController {
@@ -48,15 +49,16 @@ export class AppsController {
4849 return this . appsService . getApp ( pipeline , phase , app ) ;
4950 }
5051
51- @ApiOperation ( { summary : 'Create an app' } )
5252 @Post ( '/:pipeline/:phase/:app' )
53+ @UseGuards ( JwtAuthGuard )
54+ @UseGuards ( ReadonlyGuard )
5355 @HttpCode ( HttpStatus . CREATED )
56+ @ApiOperation ( { summary : 'Create an app' } )
5457 @ApiForbiddenResponse ( {
5558 description : 'Error: Unauthorized' ,
5659 type : OKDTO ,
5760 isArray : false ,
5861 } )
59- @UseGuards ( JwtAuthGuard )
6062 @ApiBearerAuth ( 'bearerAuth' )
6163 async createApp (
6264 @Param ( 'pipeline' ) pipeline : string ,
@@ -90,14 +92,15 @@ export class AppsController {
9092 return this . appsService . createApp ( app , user ) ;
9193 }
9294
93- @ApiOperation ( { summary : 'Update an app' } )
9495 @Put ( '/:pipeline/:phase/:app/:resourceVersion' )
96+ @UseGuards ( JwtAuthGuard )
97+ @UseGuards ( ReadonlyGuard )
98+ @ApiOperation ( { summary : 'Update an app' } )
9599 @ApiForbiddenResponse ( {
96100 description : 'Error: Unauthorized' ,
97101 type : OKDTO ,
98102 isArray : false ,
99103 } )
100- @UseGuards ( JwtAuthGuard )
101104 @ApiBearerAuth ( 'bearerAuth' )
102105 async updateApp (
103106 @Param ( 'pipeline' ) pipeline : string ,
@@ -123,14 +126,15 @@ export class AppsController {
123126 return this . appsService . updateApp ( app , resourceVersion , user ) ;
124127 }
125128
126- @ApiOperation ( { summary : 'Delete an app' } )
127129 @Delete ( '/:pipeline/:phase/:app' )
130+ @UseGuards ( JwtAuthGuard )
131+ @UseGuards ( ReadonlyGuard )
132+ @ApiOperation ( { summary : 'Delete an app' } )
128133 @ApiForbiddenResponse ( {
129134 description : 'Error: Unauthorized' ,
130135 type : OKDTO ,
131136 isArray : false ,
132137 } )
133- @UseGuards ( JwtAuthGuard )
134138 @ApiBearerAuth ( 'bearerAuth' )
135139 async deleteApp (
136140 @Param ( 'pipeline' ) pipeline : string ,
@@ -147,14 +151,15 @@ export class AppsController {
147151 return this . appsService . deleteApp ( pipeline , phase , app , user ) ;
148152 }
149153
150- @ApiOperation ( { summary : 'Start a Pull Request App' } )
151154 @Post ( '/pullrequest' )
155+ @UseGuards ( JwtAuthGuard )
156+ @UseGuards ( ReadonlyGuard )
157+ @ApiOperation ( { summary : 'Start a Pull Request App' } )
152158 @ApiForbiddenResponse ( {
153159 description : 'Error: Unauthorized' ,
154160 type : OKDTO ,
155161 isArray : false ,
156162 } )
157- @UseGuards ( JwtAuthGuard )
158163 @ApiBearerAuth ( 'bearerAuth' )
159164 async startPullRequest ( @Body ( ) body : any ) {
160165 return this . appsService . createPRApp (
@@ -165,14 +170,14 @@ export class AppsController {
165170 ) ;
166171 }
167172
168- @ApiOperation ( { summary : 'Download the app templates' } )
169173 @Get ( '/:pipeline/:phase/:app/download' )
174+ @UseGuards ( JwtAuthGuard )
175+ @ApiOperation ( { summary : 'Download the app templates' } )
170176 @ApiForbiddenResponse ( {
171177 description : 'Error: Unauthorized' ,
172178 type : OKDTO ,
173179 isArray : false ,
174180 } )
175- @UseGuards ( JwtAuthGuard )
176181 @ApiBearerAuth ( 'bearerAuth' )
177182 async downloadAppTemplates (
178183 @Param ( 'pipeline' ) pipeline : string ,
@@ -182,14 +187,15 @@ export class AppsController {
182187 return this . appsService . getTemplate ( pipeline , phase , app ) ;
183188 }
184189
185- @ApiOperation ( { summary : 'Restart/Reload an app' } )
186190 @Get ( '/:pipeline/:phase/:app/restart' )
191+ @UseGuards ( JwtAuthGuard )
192+ @UseGuards ( ReadonlyGuard )
193+ @ApiOperation ( { summary : 'Restart/Reload an app' } )
187194 @ApiForbiddenResponse ( {
188195 description : 'Error: Unauthorized' ,
189196 type : OKDTO ,
190197 isArray : false ,
191198 } )
192- @UseGuards ( JwtAuthGuard )
193199 @ApiBearerAuth ( 'bearerAuth' )
194200 async restartApp (
195201 @Param ( 'pipeline' ) pipeline : string ,
@@ -207,14 +213,14 @@ export class AppsController {
207213 return this . appsService . restartApp ( pipeline , phase , app , user ) ;
208214 }
209215
210- @ApiOperation ( { summary : 'Get the app pods' } )
211216 @Get ( '/:pipeline/:phase/:app/pods' )
217+ @UseGuards ( JwtAuthGuard )
218+ @ApiOperation ( { summary : 'Get the app pods' } )
212219 @ApiForbiddenResponse ( {
213220 description : 'Error: Unauthorized' ,
214221 type : OKDTO ,
215222 isArray : false ,
216223 } )
217- @UseGuards ( JwtAuthGuard )
218224 @ApiBearerAuth ( 'bearerAuth' )
219225 async getPods (
220226 @Param ( 'pipeline' ) pipeline : string ,
@@ -224,14 +230,15 @@ export class AppsController {
224230 return this . appsService . getPods ( pipeline , phase , app ) ;
225231 }
226232
227- @ApiOperation ( { summary : 'Start a container console' } )
228233 @Post ( '/:pipeline/:phase/:app/console' )
234+ @UseGuards ( JwtAuthGuard )
235+ @UseGuards ( ReadonlyGuard )
236+ @ApiOperation ( { summary : 'Start a container console' } )
229237 @ApiForbiddenResponse ( {
230238 description : 'Error: Unauthorized' ,
231239 type : OKDTO ,
232240 isArray : false ,
233241 } )
234- @UseGuards ( JwtAuthGuard )
235242 @ApiBearerAuth ( 'bearerAuth' )
236243 async execInContainer (
237244 @Param ( 'pipeline' ) pipeline : string ,
0 commit comments