Add an option to allow passing X-Forwarded headers to the application#9955
Merged
nielsm5 merged 8 commits intorelease/9.0from Nov 25, 2025
Merged
Add an option to allow passing X-Forwarded headers to the application#9955nielsm5 merged 8 commits intorelease/9.0from
nielsm5 merged 8 commits intorelease/9.0from
Conversation
nielsm5
reviewed
Nov 20, 2025
| // This filter converts x-forwarded headers to their corresponding `normal` headers. Eg. `X-Forwarded-Proto` sets HttpServletRequest.isSecure to `true`. | ||
| http.addFilterBefore(new ForwardedHeaderFilter(), SecurityContextHolderFilter.class); | ||
| if (!allowForwardedHeadersPassthrough) { | ||
| // This filter removes x-forwarded headers and converts them to their corresponding `normal` headers. Eg. `X-Forwarded-Proto` sets HttpServletRequest.isSecure to `true`. |
Member
There was a problem hiding this comment.
The filter does more than just blocking the headers. It manipulates the request, it will use the 'forwarded' information as scheme, secure, host, post, remote-address fields.
nielsm5
reviewed
Nov 21, 2025
| * @see <a href="https://tools.ietf.org/html/rfc7239">https://tools.ietf.org/html/rfc7239</a> | ||
| * @see <a href="https://docs.spring.io/spring-framework/reference/web/webmvc/filters.html#filters-forwarded-headers">Forwarded Headers</a> | ||
| */ | ||
| public class CustomizedForwardedHeaderFilter extends OncePerRequestFilter { |
Member
There was a problem hiding this comment.
Misschien hier //NOSONAR zetten?
|
nielsm5
approved these changes
Nov 25, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Changes
Add an option to allow passing X-Forwarded headers to the application and pipelines. By default this is
truefor this version, for backwards compatibility, but in future this should default tofalsefor security.Pull Request Checklist
Title
Issues
Backports
Documentation
Tests
Breaking changes