bug6099: use only client IP for bearer token-based authentication blocking;

client IP is determined from *last* element of X-Forwarded-For which the
AWS ALB will append by default, defaulting to the HttpServletRequest's
getRemoteAddr().
This commit is contained in:
Axel Uhl
2025-03-18 18:23:52 +01:00
parent c1211cb3d8
commit c754223f02
6 changed files with 34 additions and 35 deletions
@@ -29,7 +29,8 @@ public abstract class HttpRequestUtils {
final String xForwardedFor = req.getHeader(X_FORWARDED_FOR_HEADER);
final String result;
if (Util.hasLength(xForwardedFor)) {
result = xForwardedFor.split(" +")[0];
final String[] ips = xForwardedFor.split(" +");
result = ips[ips.length-1];
} else {
result = req.getRemoteAddr();
}