Skip to content

Commit 9940f8f

Browse files
committed
Added Logging browser and client ip
1 parent 2f6520e commit 9940f8f

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/main/java/com/app/config/GenerateTokenForUserFilter.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,17 @@ public Authentication attemptAuthentication(HttpServletRequest request, HttpServ
4040
JSONObject userJSON = new JSONObject(jsonString);
4141
String username = userJSON.getString("username");
4242
String password = userJSON.getString("password");
43-
log.info("username:{} and paswword:{} \n", username, password);
43+
String browser = request.getHeader("User-Agent")!= null?request.getHeader("User-Agent"):"";
44+
String ip = request.getRemoteAddr();
45+
String forwardIp = request.getHeader("x-forwarded-fo")!= null?request.getHeader("x-forwarded-fo"):"";
46+
47+
log.info("ip:{}, \nproxy-ip:{} \nbrowser:{} \nuser:{} \npwd:{} \n----",
48+
request.getRemoteAddr(),
49+
request.getHeader("x-forwarded-for"),
50+
request.getHeader("User-Agent"),
51+
username,
52+
password
53+
);
4454
//final UsernamePasswordAuthenticationToken loginToken = new UsernamePasswordAuthenticationToken("demo", "demo");
4555
final UsernamePasswordAuthenticationToken authToken = new UsernamePasswordAuthenticationToken(username, password);
4656
return getAuthenticationManager().authenticate(authToken); // This will take to successfulAuthentication or faliureAuthentication function

0 commit comments

Comments
 (0)