Skip to content

Commit bca5558

Browse files
authored
Merge pull request #234 from Gbangbolaoluwagbemiga/fix/issues-62-6-17-25
fix: require maintainer auth on POST /github/sync/:owner/:repo
2 parents 9653d5f + 2d85b6c commit bca5558

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

src/github/github.controller.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,32 @@
1-
import { Controller, DefaultValuePipe, Param, ParseIntPipe, Post, Query } from '@nestjs/common';
2-
import { ApiTags, ApiQuery } from '@nestjs/swagger';
1+
import {
2+
Controller,
3+
DefaultValuePipe,
4+
Param,
5+
ParseIntPipe,
6+
Post,
7+
Query,
8+
UseGuards,
9+
} from '@nestjs/common';
10+
import { ApiTags, ApiQuery, ApiBearerAuth } from '@nestjs/swagger';
311
import { GithubSyncService } from './github-sync.service';
12+
import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard';
13+
import { RolesGuard } from '../auth/guards/roles.guard';
14+
import { Roles } from '../auth/decorators/roles.decorator';
15+
import { UserRole } from '../common/enums';
416

517
@ApiTags('github')
618
@Controller('github')
719
export class GithubController {
820
constructor(private readonly syncService: GithubSyncService) {}
921

22+
// #62 — this endpoint triggers a full repository sync (writes + GitHub API
23+
// calls under this server's credentials) and was completely unauthenticated.
24+
// Restricted to authenticated maintainers.
1025
@Post('sync/:owner/:repo')
26+
@ApiBearerAuth()
1127
@ApiQuery({ name: 'page', required: false, type: Number })
28+
@UseGuards(JwtAuthGuard, RolesGuard)
29+
@Roles(UserRole.MAINTAINER)
1230
sync(
1331
@Param('owner') owner: string,
1432
@Param('repo') repo: string,

0 commit comments

Comments
 (0)