pass client ip as url param

This commit is contained in:
Ersun Warncke 2019-11-19 12:08:35 -04:00
parent 3c28b30680
commit b1262ff06e

View file

@ -133,7 +133,11 @@ public class Oauth2Filter implements Filter {
String authHeader = request.getHeader("Authorization"); String authHeader = request.getHeader("Authorization");
if (authHeader != null) { 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); StringTokenizer st = new StringTokenizer(authHeader);
if (st.hasMoreTokens()) { if (st.hasMoreTokens()) {
String basic = st.nextToken(); String basic = st.nextToken();
@ -157,7 +161,8 @@ public class Oauth2Filter implements Filter {
Instance.jsonFactory, Instance.jsonFactory,
new GenericUrl( new GenericUrl(
oauth2.getOauth2Server() oauth2.getOauth2Server()
+ "/oauth/token" + "/oauth/token?client_ip="
+ clientIp
), ),
username, username,
password password