Skip to content

Commit a5e4c36

Browse files
authored
Merge pull request #1565 from rocket-admin/backend_security_report
feat: add throttling to user invitation and login endpoints
2 parents 468d78a + 9b44ef8 commit a5e4c36

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

backend/src/entities/company-info/company-info.controller.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ export class CompanyInfoController {
224224
type: InvitedUserInCompanyAndConnectionGroupDs,
225225
})
226226
@UseGuards(CompanyAdminGuard)
227+
@Throttle({ default: { limit: isTest() ? 200 : 10, ttl: 60000 } })
227228
@Put('user/:companyId')
228229
async inviteUserInCompanyAndConnectionGroup(
229230
@UserId() userId: string,

backend/src/entities/user/user.controller.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ import { UserSettingsDataRequestDto } from './dto/user-settings-data-request.dto
7171
import { RequestRestUserPasswordDto } from './dto/request-rest-user-password.dto.js';
7272
import { SuccessResponse } from '../../microservices/saas-microservice/data-structures/common-responce.ds.js';
7373
import { Timeout } from '../../decorators/timeout.decorator.js';
74+
import { Throttle } from '@nestjs/throttler';
75+
import { isTest } from '../../helpers/app/is-test.js';
7476

7577
@UseInterceptors(SentryInterceptor)
7678
@Timeout()
@@ -143,6 +145,7 @@ export class UserController {
143145
description: 'Login successful.',
144146
type: TokenExpDs,
145147
})
148+
@Throttle({ default: { limit: isTest() ? 200 : 5, ttl: 60000 } })
146149
@Post('user/login/')
147150
async usualLogin(
148151
@Res({ passthrough: true }) response: Response,
@@ -294,6 +297,7 @@ export class UserController {
294297
description: 'Password reset requested.',
295298
type: OperationResultMessageDs,
296299
})
300+
@Throttle({ default: { limit: isTest() ? 200 : 5, ttl: 60000 } })
297301
@Post('user/password/reset/request/')
298302
async askResetUserPassword(@Body() emailData: RequestRestUserPasswordDto): Promise<OperationResultMessageDs> {
299303
return await this.requestResetUserPasswordUseCase.execute(emailData, InTransactionEnum.ON);

0 commit comments

Comments
 (0)