Rossen Stoyanchev opened SPR-16668 and commented
Currently "Forwarded" headers are consumed indirectly when building links with ServletUriComponentsBuilder, MvcUriComponentsBuilder or in CORS checks. While the behavior is documented, it can be overlooked, and it would be better to differ the treatment of such headers to the ForwadedHeaderFilter which requires an explicit choice, handles such headers more efficiently (once per request), is more comprehensive as a solution (e.g. applies to redirects too), and provides a removeOnly flag which can discard such headers when the application is not behind a trusted proxy.
On the implementation level we would keep the current UriComponentsBuilder.fromHttpRequest which encapsulates the actual handling of such headers, and switch the above to use UriComponentsBuilder.fromUri instead.
In the mean time, applications can use the ForwadedHeaderFilter which removes those headers (by wrapping the request), either consuming or ignoring them, and thus providing a single point of handling.
Affects: 5.0.4
Issue Links:
Referenced from: commits 4da43de
0 votes, 6 watchers
Rossen Stoyanchev opened SPR-16668 and commented
Currently "Forwarded" headers are consumed indirectly when building links with
ServletUriComponentsBuilder,MvcUriComponentsBuilderor in CORS checks. While the behavior is documented, it can be overlooked, and it would be better to differ the treatment of such headers to theForwadedHeaderFilterwhich requires an explicit choice, handles such headers more efficiently (once per request), is more comprehensive as a solution (e.g. applies to redirects too), and provides aremoveOnlyflag which can discard such headers when the application is not behind a trusted proxy.On the implementation level we would keep the current
UriComponentsBuilder.fromHttpRequestwhich encapsulates the actual handling of such headers, and switch the above to useUriComponentsBuilder.fromUriinstead.In the mean time, applications can use the
ForwadedHeaderFilterwhich removes those headers (by wrapping the request), either consuming or ignoring them, and thus providing a single point of handling.Affects: 5.0.4
Issue Links:
Referenced from: commits 4da43de
0 votes, 6 watchers