Skip to content

Commit

Permalink
Merge pull request #33 from BenrhayemRacem/throttle
Browse files Browse the repository at this point in the history
add throttler guard to protect againt brute force attack
  • Loading branch information
BenrhayemRacem committed May 8, 2023
2 parents 9a68186 + 92d4ddf commit d4c5387
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"@nestjs/passport": "^9.0.3",
"@nestjs/platform-express": "^9.0.0",
"@nestjs/serve-static": "^3.0.1",
"@nestjs/throttler": "^4.0.0",
"bcrypt": "^5.1.0",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.0",
Expand Down
14 changes: 13 additions & 1 deletion backend/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { CommentsModule } from './comments/comments.module';
import configuration from './config/configuration';
import { ServeStaticModule } from '@nestjs/serve-static';
import { join } from 'path';
import { ThrottlerModule, ThrottlerGuard } from '@nestjs/throttler';
import { APP_GUARD } from '@nestjs/core';
@Module({
imports: [
UsersModule,
Expand All @@ -22,8 +24,18 @@ import { join } from 'path';
ServeStaticModule.forRoot({
rootPath: join(__dirname, '..', 'uploads'),
}),
ThrottlerModule.forRoot({
ttl: 60,
limit: 10,
}),
],
controllers: [AppController],
providers: [AppService],
providers: [
AppService,
{
provide: APP_GUARD,
useClass: ThrottlerGuard,
},
],
})
export class AppModule {}

0 comments on commit d4c5387

Please sign in to comment.