From b1262ff06ef6ee57fd13c1ed6640bd3b7e334bec Mon Sep 17 00:00:00 2001 From: Ersun Warncke Date: Tue, 19 Nov 2019 12:08:35 -0400 Subject: [PATCH] pass client ip as url param --- .../java/uk/ac/ic/wlgitbridge/server/Oauth2Filter.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/server/Oauth2Filter.java b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/server/Oauth2Filter.java index 631401c759..bbf2696cd3 100644 --- a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/server/Oauth2Filter.java +++ b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/server/Oauth2Filter.java @@ -133,7 +133,11 @@ public class Oauth2Filter implements Filter { String authHeader = request.getHeader("Authorization"); if (authHeader != null) { - Log.info("[{}] Authorization header present"); + String clientIp = request.getHeader("X-Forwarded-For"); + if (clientIp == null) { + clientIp = request.getRemoteAddr(); + } + Log.info("[{}] Authorization header present", clientIp); StringTokenizer st = new StringTokenizer(authHeader); if (st.hasMoreTokens()) { String basic = st.nextToken(); @@ -157,7 +161,8 @@ public class Oauth2Filter implements Filter { Instance.jsonFactory, new GenericUrl( oauth2.getOauth2Server() - + "/oauth/token" + + "/oauth/token?client_ip=" + + clientIp ), username, password