- Adicionar refresh tokens para renovação automática de tokens - Implementar controle de sessões simultâneas - Adicionar blacklist de tokens para logout seguro - Implementar rate limiting para proteção contra ataques - Melhorar detecção de IP e identificação de sessão atual - Adicionar endpoints para gerenciamento de sessões - Corrigir inconsistências na validação de usuário - Atualizar configuração Redis com nova conexão
48 lines
1.6 KiB
TypeScript
48 lines
1.6 KiB
TypeScript
import { Module } from '@nestjs/common';
|
|
import { JwtModule } from '@nestjs/jwt';
|
|
import { PassportModule } from '@nestjs/passport';
|
|
import { AuthService } from './auth.service';
|
|
import { JwtStrategy } from '../strategies/jwt-strategy';
|
|
import { RedisModule } from 'src/core/configs/cache/redis.module';
|
|
import { UsersModule } from '../users/users.module';
|
|
import { AuthController } from './auth.controller';
|
|
import { CqrsModule } from '@nestjs/cqrs';
|
|
import { ConfigModule, ConfigService } from '@nestjs/config';
|
|
import { AuthenticateUserHandler } from './commands/authenticate-user.service';
|
|
import { TokenBlacklistService } from '../services/token-blacklist.service';
|
|
import { RateLimitingService } from '../services/rate-limiting.service';
|
|
import { RefreshTokenService } from '../services/refresh-token.service';
|
|
import { SessionManagementService } from '../services/session-management.service';
|
|
|
|
@Module({
|
|
imports: [
|
|
CqrsModule,
|
|
ConfigModule,
|
|
JwtModule.registerAsync({
|
|
imports: [ConfigModule],
|
|
useFactory: async (configService: ConfigService) => ({
|
|
secret: configService.get<string>('JWT_SECRET'),
|
|
signOptions: {
|
|
expiresIn: configService.get<string>('JWT_EXPIRES_IN'),
|
|
},
|
|
}),
|
|
inject: [ConfigService],
|
|
}),
|
|
PassportModule.register({ defaultStrategy: 'jwt' }),
|
|
RedisModule,
|
|
UsersModule,
|
|
],
|
|
controllers: [AuthController],
|
|
providers: [
|
|
AuthService,
|
|
JwtStrategy,
|
|
TokenBlacklistService,
|
|
RateLimitingService,
|
|
RefreshTokenService,
|
|
SessionManagementService,
|
|
AuthenticateUserHandler
|
|
],
|
|
exports: [AuthService],
|
|
})
|
|
export class AuthModule {}
|