diff --git a/features/sso/backend-api/src/common/security/throttling/throttler-storage-redis.service.ts b/features/sso/backend-api/src/common/security/throttling/throttler-storage-redis.service.ts index 01daa7620..032f19baa 100755 --- a/features/sso/backend-api/src/common/security/throttling/throttler-storage-redis.service.ts +++ b/features/sso/backend-api/src/common/security/throttling/throttler-storage-redis.service.ts @@ -19,13 +19,13 @@ export class ThrottlerStorageRedisService private redisClient: RedisClientType; private readonly prefix = "throttle:"; - constructor(private readonly redisConfig: { host: string; port: number }) { + constructor(private readonly redisConfig: { host: string; port: number; password?: string }) { this.redisClient = createClient({ socket: { host: this.redisConfig.host, port: this.redisConfig.port, }, - // No username or password - completely disable authentication + ...(this.redisConfig.password && { password: this.redisConfig.password }), }); } diff --git a/features/sso/backend-api/src/common/security/throttling/throttling.module.ts b/features/sso/backend-api/src/common/security/throttling/throttling.module.ts index 9119e6e24..fe8f209ff 100755 --- a/features/sso/backend-api/src/common/security/throttling/throttling.module.ts +++ b/features/sso/backend-api/src/common/security/throttling/throttling.module.ts @@ -55,6 +55,7 @@ import { ThrottlerStorageRedisService } from "./throttler-storage-redis.service" storage: new ThrottlerStorageRedisService({ host: redisHost, port: redisPort, + ...(process.env.DATABASE_REDIS_PASSWORD && { password: process.env.DATABASE_REDIS_PASSWORD }), }), errorMessage: "Too many requests. Please try again later.", };