|
@@ -1,9 +1,19 @@
|
|
-[[webflux-redirect-https]]
|
|
|
|
-= Redirect to HTTPS
|
|
|
|
|
|
+[[webflux-http]]
|
|
|
|
+= HTTP
|
|
|
|
|
|
-HTTPS is required to provide a secure application.
|
|
|
|
-Spring Security can be configured to perform a redirect to https using the following Java Configuration:
|
|
|
|
|
|
+All HTTP based communication should be protected <<http,using TLS>>.
|
|
|
|
|
|
|
|
+Below you can find details around WebFlux specific features that assist with HTTPS usage.
|
|
|
|
+
|
|
|
|
+[[webflux-http-redirect]]
|
|
|
|
+== Redirect to HTTPS
|
|
|
|
+
|
|
|
|
+If a client makes a request using HTTP rather than HTTPS, Spring Security can be configured to redirect to HTTPS.
|
|
|
|
+
|
|
|
|
+For example, the following Java configuration will redirect any HTTP requests to HTTPS:
|
|
|
|
+
|
|
|
|
+.Redirect to HTTPS
|
|
|
|
+====
|
|
[source,java]
|
|
[source,java]
|
|
----
|
|
----
|
|
@Bean
|
|
@Bean
|
|
@@ -14,11 +24,14 @@ SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
|
|
return http.build();
|
|
return http.build();
|
|
}
|
|
}
|
|
----
|
|
----
|
|
|
|
+====
|
|
|
|
|
|
The configuration can easily be wrapped around an if statement to only be turned on in production.
|
|
The configuration can easily be wrapped around an if statement to only be turned on in production.
|
|
Alternatively, it can be enabled by looking for a property about the request that only happens in production.
|
|
Alternatively, it can be enabled by looking for a property about the request that only happens in production.
|
|
For example, if the production environment adds a header named `X-Forwarded-Proto` the following Java Configuration could be used:
|
|
For example, if the production environment adds a header named `X-Forwarded-Proto` the following Java Configuration could be used:
|
|
|
|
|
|
|
|
+.Redirect to HTTPS when X-Forwarded
|
|
|
|
+====
|
|
[source,java]
|
|
[source,java]
|
|
----
|
|
----
|
|
@Bean
|
|
@Bean
|
|
@@ -32,3 +45,14 @@ SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
|
|
return http.build();
|
|
return http.build();
|
|
}
|
|
}
|
|
----
|
|
----
|
|
|
|
+====
|
|
|
|
+
|
|
|
|
+[[webflux-hsts]]
|
|
|
|
+== Strict Transport Security
|
|
|
|
+
|
|
|
|
+Spring Security provides support for <<servlet-headers-hsts,Strict Transport Security>> and enables it by default.
|
|
|
|
+
|
|
|
|
+[[webflux-http-proxy-server]]
|
|
|
|
+== Proxy Server Configuration
|
|
|
|
+
|
|
|
|
+Spring Security <<http-proxy-servers,integrates with proxy servers>>.
|