From 753fea68ed3556e640ca11710e5c9adf4514dccd Mon Sep 17 00:00:00 2001 From: williamlardier Date: Thu, 26 Dec 2024 14:03:12 +0100 Subject: [PATCH] Remove old TODO on getClientIp and remove duplicate logic Issue: ARSN-453 --- lib/policyEvaluator/requestUtils.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/policyEvaluator/requestUtils.ts b/lib/policyEvaluator/requestUtils.ts index 539b198d2..5b07f9e54 100644 --- a/lib/policyEvaluator/requestUtils.ts +++ b/lib/policyEvaluator/requestUtils.ts @@ -8,9 +8,6 @@ export interface S3Config { } } -// TODO -// I'm not sure about this behavior. -// Should it returns string | string[] | undefined or string ? /** * getClientIp - Gets the client IP from the request * @param request - http request object @@ -20,7 +17,6 @@ export interface S3Config { export function getClientIp(request: IncomingMessage, s3config?: S3Config): string { const requestConfig = s3config?.requests; const remoteAddress = request.socket.remoteAddress; - // TODO What to do if clientIp === undefined ? const clientIp = remoteAddress?.toString() ?? ''; if (requestConfig) { const { trustedProxyCIDRs, extractClientIPFromHeader } = requestConfig; @@ -39,5 +35,5 @@ export function getClientIp(request: IncomingMessage, s3config?: S3Config): stri } } } - return clientIp?.toString() ?? ''; + return clientIp; }