From 5fa6ecab848f1ef10acb20cce616d59c50ae5555 Mon Sep 17 00:00:00 2001 From: Maha Benzekri Date: Thu, 2 Jan 2025 12:33:07 +0100 Subject: [PATCH] fixup --- lib/policyEvaluator/requestUtils.ts | 3 +-- tests/unit/policyEvaluator/requestUtils.spec.js | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/policyEvaluator/requestUtils.ts b/lib/policyEvaluator/requestUtils.ts index ec73a9b50..7fb269cae 100644 --- a/lib/policyEvaluator/requestUtils.ts +++ b/lib/policyEvaluator/requestUtils.ts @@ -18,8 +18,7 @@ export function getClientIp(request: IncomingMessage, s3config?: S3Config): stri const requestConfig = s3config?.requests; const remoteAddress = request.socket.remoteAddress; // TODO What to do if clientIp === undefined ? - const clientIp = (requestConfig ? remoteAddress : request.headers['x-forwarded-for'] || - remoteAddress)?.toString() ?? ''; + const clientIp = remoteAddress?.toString() ?? ''; if (requestConfig) { const { trustedProxyCIDRs, extractClientIPFromHeader } = requestConfig; /** diff --git a/tests/unit/policyEvaluator/requestUtils.spec.js b/tests/unit/policyEvaluator/requestUtils.spec.js index 0f2694a0b..ffa77df99 100644 --- a/tests/unit/policyEvaluator/requestUtils.spec.js +++ b/tests/unit/policyEvaluator/requestUtils.spec.js @@ -90,7 +90,7 @@ describe('requestUtils.getClientIp', () => { }, }); const result = requestUtils.getClientIp(request, configWithoutProxy); - assert.strictEqual(result, testClientIp1); + assert.strictEqual(result, testProxyIp); }); it('should return client Ip address from socket info if the request comes via proxies and ' +