Skip to content

Conversation

KarstenSchnitter
Copy link
Contributor

This PR addresses several http headers, that may be generated by reverse proxies for incoming http requests. They are added to the request logs generated by the library, provided that certain environment variables are set. See the commit messages for details. The documentation will be changed accordingly.

Users can choose to log the following for http headers in the request logs:

* x-forwarded-for
* x-forwarded-host
* x-forwarded-proto
* x-custom-host

This requires the environment variable `LOG_SENSITIVE_CONNECTION_DATA` to be set to `true`.
If there are no headers, no fields will be added to the request logs. If there are headers, but
`LOG_SENSITIVE_CONNECTION_DATA` is set to `false`(default) the values will be logged as 'redacted'.
HA-Proxy can add certain headers for terminated ssl connections [1].
These headers can be added to the request logs if environment variable
LOG_SSL_HEADERS is set to be true. Otherwise no fields will be added
to the request logs.

[1] https://www.haproxy.com/blog/ssl-client-certificate-information-in-http-headers-and-logs/
@juergen-walter
Copy link
Member

Please align indentation method in your PR:

RequestLoggingFilterTest.java uses spaces for indentation

RequestRecordBuilder.java uses tabs

@KarstenSchnitter
Copy link
Contributor Author

The usual indentation should be using spaces as defined in https://github.com/SAP/cf-java-logging-support/blob/master/eclipse-formatter-settings.xml. Unfortunately, I once formatted several files using tabs. I reformatted the RequestRecordBuilder as a whole. I do not want to run the formatter over the whole repository, since this breaks file history too much for me.

@juergen-walter
Copy link
Member

The usual indentation should be using spaces as defined in https://github.com/SAP/cf-java-logging-support/blob/master/eclipse-formatter-settings.xml. Unfortunately, I once formatted several files using tabs. I reformatted the RequestRecordBuilder as a whole. I do not want to run the formatter over the whole repository, since this breaks file history too much for me.

fine for me., thanks for the pointer. Just got confused by different indentation methods.

Copy link
Member

@christiand93 christiand93 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@KarstenSchnitter KarstenSchnitter merged commit b349254 into master Aug 10, 2021
@KarstenSchnitter KarstenSchnitter deleted the log-http-headers-request branch August 10, 2021 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants