Skip to content
This repository has been archived by the owner on Oct 2, 2023. It is now read-only.

Commit

Permalink
Merge pull request #291 from tatlax3636/forward-headers
Browse files Browse the repository at this point in the history
Add x-forwarded-for to logs
  • Loading branch information
tatlax3636 authored Aug 22, 2022
2 parents acd9f8e + beddf33 commit ddabe2e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<artifactId>api</artifactId>
<packaging>jar</packaging>
<name>${project.groupId}:${project.artifactId}</name>
<version>3.4.46</version>
<version>3.4.47</version>
<description>Hygieia Rest API Layer</description>
<url>https://github.com/Hygieia/api</url>

Expand Down Expand Up @@ -59,7 +59,7 @@

<properties>
<!-- Dependencies -->
<com.capitalone.dashboard.core.version>3.15.43</com.capitalone.dashboard.core.version>
<com.capitalone.dashboard.core.version>3.15.44</com.capitalone.dashboard.core.version>
<spring-security.version>4.2.18.RELEASE</spring-security.version>
<tomcat.version>8.5.70</tomcat.version>
<commons-beanutils.version>1.9.4</commons-beanutils.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ public class LoggingFilter implements Filter {

private static final String API_USER_KEY = "apiUser";

private static final String X_FORWARDED_FOR = "x-forwarded-for";

private static final String UNKNOWN_USER = "unknown";


Expand Down Expand Up @@ -98,6 +100,8 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha
try {

requestLog.setClient(httpServletRequest.getRemoteAddr());
String x_forwarded_for = bufferedRequest.getHeader(X_FORWARDED_FOR);
requestLog.setXForwardedFor(x_forwarded_for);
requestLog.setEndpoint(httpServletRequest.getRequestURI());
requestLog.setMethod(httpServletRequest.getMethod());
requestLog.setParameter(requestMap.toString());
Expand Down

0 comments on commit ddabe2e

Please sign in to comment.