Skip to content

Commit 9dd3cd9

Browse files
committed
[docs] Move Filters section under Reactive Spring Web
Issue: SPR-16394
1 parent cc379f1 commit 9dd3cd9

File tree

2 files changed

+55
-43
lines changed

2 files changed

+55
-43
lines changed

src/docs/asciidoc/web/webflux.adoc

Lines changed: 53 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ Server support is organized in two layers:
316316

317317
* <<webflux-httphandler,HttpHandler>> and server adapters -- the most basic, common API
318318
for HTTP request handling with Reactive Streams back pressure.
319-
* <<webflux-web-handler-api,WebHandler API>> -- slightly higher level but still general
319+
* <<webflux-web-handler-api>> -- slightly higher level but still general
320320
purpose server web API with filter chain style processing.
321321

322322

@@ -448,7 +448,7 @@ This can be automated through the use of
448448

449449

450450
[[webflux-web-handler-api]]
451-
=== WebHandler API
451+
=== WebHandler
452452

453453
`HttpHandler` is the lowest level contract for running on different HTTP servers.
454454
On top of that foundation, the WebHandler API provides a slightly higher level, but
@@ -564,7 +564,7 @@ content to `Flux<Part>` without collecting to a `MultiValueMap`.
564564

565565

566566
[[webflux-codecs]]
567-
=== HTTP Message Codecs
567+
=== Message Codecs
568568
[.small]#<<integration.adoc#rest-message-conversion,Same in Spring MVC>>#
569569

570570
The `spring-web` module defines the
@@ -641,6 +641,55 @@ a heartbeat and ignore.
641641

642642

643643

644+
[[webflux-filters]]
645+
=== Filters
646+
[.small]#<<web.adoc#filters,Same in Spring MVC>>#
647+
648+
As part of the <<webflux-web-handler-api>>, the `spring-web` module provides a number of
649+
`WebFilter` implementations.
650+
651+
652+
653+
[[webflux-filters-forwarded-headers]]
654+
==== Forwarded Headers
655+
[.small]#<<web.adoc#filters-forwarded-headers,Same in Spring MVC>>#
656+
657+
As a request goes through proxies such as load balancers the host, port, and
658+
scheme may change presenting a challenge for applications that need to create links
659+
to resources since the links should reflect the host, port, and scheme of the
660+
original request as seen from a client perspective.
661+
662+
https://tools.ietf.org/html/rfc7239[RFC 7239] defines the "Forwarded" HTTP header
663+
for proxies to use to provide information about the original request. There are also
664+
other non-standard headers in use such as "X-Forwarded-Host", "X-Forwarded-Port",
665+
and "X-Forwarded-Proto".
666+
667+
`ForwardedHeaderFilter` detects, extracts, and uses information from the "Forwarded"
668+
header, or from "X-Forwarded-Host", "X-Forwarded-Port", and "X-Forwarded-Proto".
669+
It wraps the request in order to overlay its host, port, and scheme and also "hides"
670+
the forwarded headers for subsequent processing.
671+
672+
Note that there are security considerations when using forwarded headers as explained
673+
in Section 8 of RFC 7239. At the application level it is difficult to determine whether
674+
forwarded headers can be trusted or not. This is why the network upstream should be
675+
configured correctly to filter out untrusted forwarded headers from the outside.
676+
677+
Applications that don't have a proxy and don't need to use forwarded headers can
678+
configure the `ForwardedHeaderFilter` to remove and ignore such headers.
679+
680+
681+
[[webflux-filters-cors]]
682+
==== CORS
683+
[.small]#<<web.adoc#filters-cors,Same in Spring MVC>>#
684+
685+
Spring WebFlux provides fine-grained support for CORS configuration through annotations on
686+
controllers. However when used with Spring Security it is advisable to rely on the built-in
687+
`CorsFilter` that must be ordered ahead of Spring Security's chain of filters.
688+
689+
See the section on <<webflux-cors>> and the <<webflux-cors-webfilter>> for more details.
690+
691+
692+
644693

645694
[[webflux-dispatcher-handler]]
646695
== DispatcherHandler
@@ -657,7 +706,7 @@ for access to the context it runs in. If `DispatcherHandler` is declared with th
657706
name "webHandler" it is in turn discovered by
658707
{api-spring-framework}/web/server/adapter/WebHttpHandlerBuilder.html[WebHttpHandlerBuilder]
659708
which puts together a request processing chain as described in
660-
<<webflux-web-handler-api,WebHandler API>>.
709+
<<webflux-web-handler-api>>.
661710

662711
Spring configuration in a WebFlux application typically contains:
663712

@@ -854,44 +903,6 @@ views through the <<webflux-config-view-resolvers,WebFlux Config>>. Default view
854903
always selected and used if they match the requested media type.
855904

856905

857-
[[webflux-filters]]
858-
== Filters
859-
[.small]#<<web.adoc#filters,Same in Spring MVC>>#
860-
861-
As part of the <<webflux-web-handler-api>>, the `spring-web` module provides a number of
862-
`WebFilter` implementations.
863-
864-
865-
866-
[[webflux-filters-forwarded-headers]]
867-
=== Forwarded Headers
868-
[.small]#<<web.adoc#filters-forwarded-headers,Same in Spring MVC>>#
869-
870-
As a request goes through proxies such as load balancers the host, port, and
871-
scheme may change presenting a challenge for applications that need to create links
872-
to resources since the links should reflect the host, port, and scheme of the
873-
original request as seen from a client perspective.
874-
875-
https://tools.ietf.org/html/rfc7239[RFC 7239] defines the "Forwarded" HTTP header
876-
for proxies to use to provide information about the original request. There are also
877-
other non-standard headers in use such as "X-Forwarded-Host", "X-Forwarded-Port",
878-
and "X-Forwarded-Proto".
879-
880-
`ForwardedHeaderFilter` detects, extracts, and uses information from the "Forwarded"
881-
header, or from "X-Forwarded-Host", "X-Forwarded-Port", and "X-Forwarded-Proto".
882-
It wraps the request in order to overlay its host, port, and scheme and also "hides"
883-
the forwarded headers for subsequent processing.
884-
885-
Note that there are security considerations when using forwarded headers as explained
886-
in Section 8 of RFC 7239. At the application level it is difficult to determine whether
887-
forwarded headers can be trusted or not. This is why the network upstream should be
888-
configured correctly to filter out untrusted forwarded headers from the outside.
889-
890-
Applications that don't have a proxy and don't need to use forwarded headers can
891-
configure the `ForwardedHeaderFilter` to remove and ignore such headers.
892-
893-
894-
895906

896907

897908
[[webflux-controller]]

src/docs/asciidoc/web/webmvc.adoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1091,12 +1091,13 @@ See <<mvc-httpcaching-shallowetag>> for more details.
10911091

10921092
[[filters-cors]]
10931093
=== CORS
1094+
[.small]#<<web-reactive.adoc#webflux-filters-cors,Same in Spring WebFlux>>#
10941095

10951096
Spring MVC provides fine-grained support for CORS configuration through annotations on
10961097
controllers. However when used with Spring Security it is advisable to rely on the built-in
10971098
`CorsFilter` that must be ordered ahead of Spring Security's chain of filters.
10981099

1099-
See the section on <<mvc-cors>> and the <<mvc-cors-filter,CorsFilter>> for more details.
1100+
See the section on <<mvc-cors>> and the <<mvc-cors-filter>> for more details.
11001101

11011102

11021103

0 commit comments

Comments
 (0)