Assist_Design/apps/bff/src/auth/guards/auth-throttle.guard.ts
2025-08-21 15:24:40 +09:00

19 lines
546 B
TypeScript

import { Injectable } from "@nestjs/common";
import { ThrottlerGuard } from "@nestjs/throttler";
@Injectable()
export class AuthThrottleGuard extends ThrottlerGuard {
protected async getTracker(req: Record<string, any>): Promise<string> {
// Track by IP address for failed login attempts
const ip =
req.headers["x-forwarded-for"]?.split(",")[0]?.trim() ||
req.headers["x-real-ip"] ||
req.connection?.remoteAddress ||
req.socket?.remoteAddress ||
req.ip ||
"unknown";
return `auth_${ip}`;
}
}