|  | @@ -21,11 +21,10 @@ You can do so with the following configuration:
 | 
	
		
			
				|  |  |  [source,java,role="primary"]
 | 
	
		
			
				|  |  |  ----
 | 
	
		
			
				|  |  |  @EnableWebSecurity
 | 
	
		
			
				|  |  | -public class WebSecurityConfig extends
 | 
	
		
			
				|  |  | -		WebSecurityConfigurerAdapter {
 | 
	
		
			
				|  |  | +public class WebSecurityConfig {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	@Override
 | 
	
		
			
				|  |  | -	protected void configure(HttpSecurity http) {
 | 
	
		
			
				|  |  | +	@Bean
 | 
	
		
			
				|  |  | +	public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
 | 
	
		
			
				|  |  |  		http
 | 
	
		
			
				|  |  |  			// ...
 | 
	
		
			
				|  |  |  			.headers(headers -> headers
 | 
	
	
		
			
				|  | @@ -33,6 +32,7 @@ public class WebSecurityConfig extends
 | 
	
		
			
				|  |  |  					.sameOrigin()
 | 
	
		
			
				|  |  |  				)
 | 
	
		
			
				|  |  |  			);
 | 
	
		
			
				|  |  | +		return http.build();
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  ----
 | 
	
	
		
			
				|  | @@ -53,8 +53,9 @@ public class WebSecurityConfig extends
 | 
	
		
			
				|  |  |  [source,kotlin,role="secondary"]
 | 
	
		
			
				|  |  |  ----
 | 
	
		
			
				|  |  |  @EnableWebSecurity
 | 
	
		
			
				|  |  | -class SecurityConfig : WebSecurityConfigurerAdapter() {
 | 
	
		
			
				|  |  | -    override fun configure(http: HttpSecurity) {
 | 
	
		
			
				|  |  | +class SecurityConfig {
 | 
	
		
			
				|  |  | +    @Bean
 | 
	
		
			
				|  |  | +    open fun filterChain(http: HttpSecurity): SecurityFilterChain {
 | 
	
		
			
				|  |  |          http {
 | 
	
		
			
				|  |  |              // ...
 | 
	
		
			
				|  |  |              headers {
 | 
	
	
		
			
				|  | @@ -63,6 +64,7 @@ class SecurityConfig : WebSecurityConfigurerAdapter() {
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +        return http.build()
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  ----
 | 
	
	
		
			
				|  | @@ -79,11 +81,10 @@ If you use Spring Security's configuration, the following adds only xref:feature
 | 
	
		
			
				|  |  |  [source,java,role="primary"]
 | 
	
		
			
				|  |  |  ----
 | 
	
		
			
				|  |  |  @EnableWebSecurity
 | 
	
		
			
				|  |  | -public class WebSecurityConfig extends
 | 
	
		
			
				|  |  | -WebSecurityConfigurerAdapter {
 | 
	
		
			
				|  |  | +public class WebSecurityConfig {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	@Override
 | 
	
		
			
				|  |  | -	protected void configure(HttpSecurity http) throws Exception {
 | 
	
		
			
				|  |  | +	@Bean
 | 
	
		
			
				|  |  | +	public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
 | 
	
		
			
				|  |  |  		http
 | 
	
		
			
				|  |  |  			// ...
 | 
	
		
			
				|  |  |  			.headers(headers -> headers
 | 
	
	
		
			
				|  | @@ -91,6 +92,7 @@ WebSecurityConfigurerAdapter {
 | 
	
		
			
				|  |  |  				.defaultsDisabled()
 | 
	
		
			
				|  |  |  				.cacheControl(withDefaults())
 | 
	
		
			
				|  |  |  			);
 | 
	
		
			
				|  |  | +		return http.build();
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  ----
 | 
	
	
		
			
				|  | @@ -111,8 +113,9 @@ WebSecurityConfigurerAdapter {
 | 
	
		
			
				|  |  |  [source,kotlin,role="secondary"]
 | 
	
		
			
				|  |  |  ----
 | 
	
		
			
				|  |  |  @EnableWebSecurity
 | 
	
		
			
				|  |  | -class SecurityConfig : WebSecurityConfigurerAdapter() {
 | 
	
		
			
				|  |  | -    override fun configure(http: HttpSecurity) {
 | 
	
		
			
				|  |  | +class SecurityConfig {
 | 
	
		
			
				|  |  | +    @Bean
 | 
	
		
			
				|  |  | +    open fun filterChain(http: HttpSecurity): SecurityFilterChain {
 | 
	
		
			
				|  |  |          http {
 | 
	
		
			
				|  |  |              // ...
 | 
	
		
			
				|  |  |              headers {
 | 
	
	
		
			
				|  | @@ -122,6 +125,7 @@ class SecurityConfig : WebSecurityConfigurerAdapter() {
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +        return http.build()
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  ----
 | 
	
	
		
			
				|  | @@ -135,14 +139,14 @@ If necessary, you can disable all of the HTTP Security response headers with the
 | 
	
		
			
				|  |  |  [source,java,role="primary"]
 | 
	
		
			
				|  |  |  ----
 | 
	
		
			
				|  |  |  @EnableWebSecurity
 | 
	
		
			
				|  |  | -public class WebSecurityConfig extends
 | 
	
		
			
				|  |  | -WebSecurityConfigurerAdapter {
 | 
	
		
			
				|  |  | +public class WebSecurityConfig {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	@Override
 | 
	
		
			
				|  |  | -	protected void configure(HttpSecurity http) throws Exception {
 | 
	
		
			
				|  |  | +	@Bean
 | 
	
		
			
				|  |  | +	public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
 | 
	
		
			
				|  |  |  		http
 | 
	
		
			
				|  |  |  			// ...
 | 
	
		
			
				|  |  |  			.headers(headers -> headers.disable());
 | 
	
		
			
				|  |  | +		return http.build();
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  ----
 | 
	
	
		
			
				|  | @@ -161,14 +165,16 @@ WebSecurityConfigurerAdapter {
 | 
	
		
			
				|  |  |  [source,kotlin,role="secondary"]
 | 
	
		
			
				|  |  |  ----
 | 
	
		
			
				|  |  |  @EnableWebSecurity
 | 
	
		
			
				|  |  | -class SecurityConfig : WebSecurityConfigurerAdapter() {
 | 
	
		
			
				|  |  | -    override fun configure(http: HttpSecurity) {
 | 
	
		
			
				|  |  | +class SecurityConfig {
 | 
	
		
			
				|  |  | +    @Bean
 | 
	
		
			
				|  |  | +    open fun filterChain(http: HttpSecurity): SecurityFilterChain {
 | 
	
		
			
				|  |  |          http {
 | 
	
		
			
				|  |  |              // ...
 | 
	
		
			
				|  |  |              headers {
 | 
	
		
			
				|  |  |                  disable()
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +        return http.build()
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  ----
 | 
	
	
		
			
				|  | @@ -194,16 +200,16 @@ If necessary, you can also disable Spring Security's cache control HTTP response
 | 
	
		
			
				|  |  |  ----
 | 
	
		
			
				|  |  |  @Configuration
 | 
	
		
			
				|  |  |  @EnableWebSecurity
 | 
	
		
			
				|  |  | -public class WebSecurityConfig extends
 | 
	
		
			
				|  |  | -WebSecurityConfigurerAdapter {
 | 
	
		
			
				|  |  | +public class WebSecurityConfig {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	@Override
 | 
	
		
			
				|  |  | -	protected void configure(HttpSecurity http) {
 | 
	
		
			
				|  |  | +	@Bean
 | 
	
		
			
				|  |  | +	public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
 | 
	
		
			
				|  |  |  		http
 | 
	
		
			
				|  |  |  			// ...
 | 
	
		
			
				|  |  |  			.headers(headers -> headers
 | 
	
		
			
				|  |  |  				.cacheControl(cache -> cache.disable())
 | 
	
		
			
				|  |  |  			);
 | 
	
		
			
				|  |  | +		return http.build();
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  ----
 | 
	
	
		
			
				|  | @@ -224,9 +230,10 @@ WebSecurityConfigurerAdapter {
 | 
	
		
			
				|  |  |  [source,kotlin,role="secondary"]
 | 
	
		
			
				|  |  |  ----
 | 
	
		
			
				|  |  |  @EnableWebSecurity
 | 
	
		
			
				|  |  | -class SecurityConfig : WebSecurityConfigurerAdapter() {
 | 
	
		
			
				|  |  | +class SecurityConfig {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    override fun configure(http: HttpSecurity) {
 | 
	
		
			
				|  |  | +    @Bean
 | 
	
		
			
				|  |  | +    open fun filterChain(http: HttpSecurity): SecurityFilterChain {
 | 
	
		
			
				|  |  |         http {
 | 
	
		
			
				|  |  |              headers {
 | 
	
		
			
				|  |  |                  cacheControl {
 | 
	
	
		
			
				|  | @@ -234,6 +241,7 @@ class SecurityConfig : WebSecurityConfigurerAdapter() {
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +        return http.build()
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  ----
 | 
	
	
		
			
				|  | @@ -252,16 +260,16 @@ However, you can disable it:
 | 
	
		
			
				|  |  |  ----
 | 
	
		
			
				|  |  |  @Configuration
 | 
	
		
			
				|  |  |  @EnableWebSecurity
 | 
	
		
			
				|  |  | -public class WebSecurityConfig extends
 | 
	
		
			
				|  |  | -		WebSecurityConfigurerAdapter {
 | 
	
		
			
				|  |  | +public class WebSecurityConfig {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	@Override
 | 
	
		
			
				|  |  | -	protected void configure(HttpSecurity http) {
 | 
	
		
			
				|  |  | +	@Bean
 | 
	
		
			
				|  |  | +	public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
 | 
	
		
			
				|  |  |  		http
 | 
	
		
			
				|  |  |  			// ...
 | 
	
		
			
				|  |  |  			.headers(headers -> headers
 | 
	
		
			
				|  |  |  				.contentTypeOptions(contentTypeOptions -> contentTypeOptions.disable())
 | 
	
		
			
				|  |  |  			);
 | 
	
		
			
				|  |  | +		return http.build();
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  ----
 | 
	
	
		
			
				|  | @@ -282,9 +290,10 @@ public class WebSecurityConfig extends
 | 
	
		
			
				|  |  |  [source,kotlin,role="secondary"]
 | 
	
		
			
				|  |  |  ----
 | 
	
		
			
				|  |  |  @EnableWebSecurity
 | 
	
		
			
				|  |  | -class SecurityConfig : WebSecurityConfigurerAdapter() {
 | 
	
		
			
				|  |  | +class SecurityConfig {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    override fun configure(http: HttpSecurity) {
 | 
	
		
			
				|  |  | +    @Bean
 | 
	
		
			
				|  |  | +    open fun filterChain(http: HttpSecurity): SecurityFilterChain {
 | 
	
		
			
				|  |  |         http {
 | 
	
		
			
				|  |  |              headers {
 | 
	
		
			
				|  |  |                  contentTypeOptions {
 | 
	
	
		
			
				|  | @@ -292,6 +301,7 @@ class SecurityConfig : WebSecurityConfigurerAdapter() {
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +        return http.build()
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  ----
 | 
	
	
		
			
				|  | @@ -310,11 +320,10 @@ The following example explicitly provides HSTS:
 | 
	
		
			
				|  |  |  [source,java,role="primary"]
 | 
	
		
			
				|  |  |  ----
 | 
	
		
			
				|  |  |  @EnableWebSecurity
 | 
	
		
			
				|  |  | -public class WebSecurityConfig extends
 | 
	
		
			
				|  |  | -WebSecurityConfigurerAdapter {
 | 
	
		
			
				|  |  | +public class WebSecurityConfig {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	@Override
 | 
	
		
			
				|  |  | -	protected void configure(HttpSecurity http) throws Exception {
 | 
	
		
			
				|  |  | +	@Bean
 | 
	
		
			
				|  |  | +	public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
 | 
	
		
			
				|  |  |  		http
 | 
	
		
			
				|  |  |  			// ...
 | 
	
		
			
				|  |  |  			.headers(headers -> headers
 | 
	
	
		
			
				|  | @@ -324,6 +333,7 @@ WebSecurityConfigurerAdapter {
 | 
	
		
			
				|  |  |  					.maxAgeInSeconds(31536000)
 | 
	
		
			
				|  |  |  				)
 | 
	
		
			
				|  |  |  			);
 | 
	
		
			
				|  |  | +		return http.build();
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  ----
 | 
	
	
		
			
				|  | @@ -347,9 +357,10 @@ WebSecurityConfigurerAdapter {
 | 
	
		
			
				|  |  |  [source,kotlin,role="secondary"]
 | 
	
		
			
				|  |  |  ----
 | 
	
		
			
				|  |  |  @EnableWebSecurity
 | 
	
		
			
				|  |  | -class SecurityConfig : WebSecurityConfigurerAdapter() {
 | 
	
		
			
				|  |  | +class SecurityConfig {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    override fun configure(http: HttpSecurity) {
 | 
	
		
			
				|  |  | +    @Bean
 | 
	
		
			
				|  |  | +    open fun filterChain(http: HttpSecurity): SecurityFilterChain {
 | 
	
		
			
				|  |  |          http {
 | 
	
		
			
				|  |  |              headers {
 | 
	
		
			
				|  |  |                  httpStrictTransportSecurity {
 | 
	
	
		
			
				|  | @@ -359,6 +370,7 @@ class SecurityConfig : WebSecurityConfigurerAdapter() {
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +        return http.build()
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  ----
 | 
	
	
		
			
				|  | @@ -376,11 +388,10 @@ You can enable HPKP headers with the following configuration:
 | 
	
		
			
				|  |  |  [source,java,role="primary"]
 | 
	
		
			
				|  |  |  ----
 | 
	
		
			
				|  |  |  @EnableWebSecurity
 | 
	
		
			
				|  |  | -public class WebSecurityConfig extends
 | 
	
		
			
				|  |  | -WebSecurityConfigurerAdapter {
 | 
	
		
			
				|  |  | +public class WebSecurityConfig {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	@Override
 | 
	
		
			
				|  |  | -	protected void configure(HttpSecurity http) throws Exception {
 | 
	
		
			
				|  |  | +	@Bean
 | 
	
		
			
				|  |  | +	public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
 | 
	
		
			
				|  |  |  		http
 | 
	
		
			
				|  |  |  			// ...
 | 
	
		
			
				|  |  |  			.headers(headers -> headers
 | 
	
	
		
			
				|  | @@ -390,6 +401,7 @@ WebSecurityConfigurerAdapter {
 | 
	
		
			
				|  |  |  					.addSha256Pins("d6qzRu9zOECb90Uez27xWltNsj0e1Md7GkYYkVoZWmM=", "E9CZ9INDbd+2eRQozYqqbQ2yXLVKB9+xcprMF+44U1g=")
 | 
	
		
			
				|  |  |  				)
 | 
	
		
			
				|  |  |  			);
 | 
	
		
			
				|  |  | +		return http.build();
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  ----
 | 
	
	
		
			
				|  | @@ -416,9 +428,10 @@ WebSecurityConfigurerAdapter {
 | 
	
		
			
				|  |  |  [source,kotlin,role="secondary"]
 | 
	
		
			
				|  |  |  ----
 | 
	
		
			
				|  |  |  @EnableWebSecurity
 | 
	
		
			
				|  |  | -class SecurityConfig : WebSecurityConfigurerAdapter() {
 | 
	
		
			
				|  |  | +class SecurityConfig {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    override fun configure(http: HttpSecurity) {
 | 
	
		
			
				|  |  | +    @Bean
 | 
	
		
			
				|  |  | +    open fun filterChain(http: HttpSecurity): SecurityFilterChain {
 | 
	
		
			
				|  |  |          http {
 | 
	
		
			
				|  |  |              headers {
 | 
	
		
			
				|  |  |                  httpPublicKeyPinning {
 | 
	
	
		
			
				|  | @@ -429,6 +442,7 @@ class SecurityConfig : WebSecurityConfigurerAdapter() {
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +        return http.build()
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  ----
 | 
	
	
		
			
				|  | @@ -447,11 +461,10 @@ For example, the following configuration specifies that Spring Security should n
 | 
	
		
			
				|  |  |  [source,java,role="primary"]
 | 
	
		
			
				|  |  |  ----
 | 
	
		
			
				|  |  |  @EnableWebSecurity
 | 
	
		
			
				|  |  | -public class WebSecurityConfig extends
 | 
	
		
			
				|  |  | -WebSecurityConfigurerAdapter {
 | 
	
		
			
				|  |  | +public class WebSecurityConfig {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	@Override
 | 
	
		
			
				|  |  | -	protected void configure(HttpSecurity http) throws Exception {
 | 
	
		
			
				|  |  | +	@Bean
 | 
	
		
			
				|  |  | +	public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
 | 
	
		
			
				|  |  |  		http
 | 
	
		
			
				|  |  |  			// ...
 | 
	
		
			
				|  |  |  			.headers(headers -> headers
 | 
	
	
		
			
				|  | @@ -459,6 +472,7 @@ WebSecurityConfigurerAdapter {
 | 
	
		
			
				|  |  |  					.sameOrigin()
 | 
	
		
			
				|  |  |  				)
 | 
	
		
			
				|  |  |  			);
 | 
	
		
			
				|  |  | +		return http.build();
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  ----
 | 
	
	
		
			
				|  | @@ -481,9 +495,10 @@ WebSecurityConfigurerAdapter {
 | 
	
		
			
				|  |  |  [source,kotlin,role="secondary"]
 | 
	
		
			
				|  |  |  ----
 | 
	
		
			
				|  |  |  @EnableWebSecurity
 | 
	
		
			
				|  |  | -class SecurityConfig : WebSecurityConfigurerAdapter() {
 | 
	
		
			
				|  |  | +class SecurityConfig {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    override fun configure(http: HttpSecurity) {
 | 
	
		
			
				|  |  | +    @Bean
 | 
	
		
			
				|  |  | +    open fun filterChain(http: HttpSecurity): SecurityFilterChain {
 | 
	
		
			
				|  |  |          http {
 | 
	
		
			
				|  |  |              headers {
 | 
	
		
			
				|  |  |                  frameOptions {
 | 
	
	
		
			
				|  | @@ -491,6 +506,7 @@ class SecurityConfig : WebSecurityConfigurerAdapter() {
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +        return http.build()
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  ----
 | 
	
	
		
			
				|  | @@ -509,11 +525,10 @@ For example, the following configuration specifies that Spring Security should n
 | 
	
		
			
				|  |  |  [source,java,role="primary"]
 | 
	
		
			
				|  |  |  ----
 | 
	
		
			
				|  |  |  @EnableWebSecurity
 | 
	
		
			
				|  |  | -public class WebSecurityConfig extends
 | 
	
		
			
				|  |  | -WebSecurityConfigurerAdapter {
 | 
	
		
			
				|  |  | +public class WebSecurityConfig {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	@Override
 | 
	
		
			
				|  |  | -	protected void configure(HttpSecurity http) throws Exception {
 | 
	
		
			
				|  |  | +	@Bean
 | 
	
		
			
				|  |  | +	public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
 | 
	
		
			
				|  |  |  		http
 | 
	
		
			
				|  |  |  			// ...
 | 
	
		
			
				|  |  |  			.headers(headers -> headers
 | 
	
	
		
			
				|  | @@ -521,6 +536,7 @@ WebSecurityConfigurerAdapter {
 | 
	
		
			
				|  |  |  					.block(false)
 | 
	
		
			
				|  |  |  				)
 | 
	
		
			
				|  |  |  			);
 | 
	
		
			
				|  |  | +		return http.build();
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  ----
 | 
	
	
		
			
				|  | @@ -541,9 +557,10 @@ WebSecurityConfigurerAdapter {
 | 
	
		
			
				|  |  |  [source,kotlin,role="secondary"]
 | 
	
		
			
				|  |  |  ----
 | 
	
		
			
				|  |  |  @EnableWebSecurity
 | 
	
		
			
				|  |  | -class SecurityConfig : WebSecurityConfigurerAdapter() {
 | 
	
		
			
				|  |  | +class SecurityConfig {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    override fun configure(http: HttpSecurity) {
 | 
	
		
			
				|  |  | +    @Bean
 | 
	
		
			
				|  |  | +    open fun filterChain(http: HttpSecurity): SecurityFilterChain {
 | 
	
		
			
				|  |  |          // ...
 | 
	
		
			
				|  |  |          http {
 | 
	
		
			
				|  |  |              headers {
 | 
	
	
		
			
				|  | @@ -552,6 +569,7 @@ class SecurityConfig : WebSecurityConfigurerAdapter() {
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +        return http.build()
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  ----
 | 
	
	
		
			
				|  | @@ -581,11 +599,10 @@ Given the preceding security policy, you can enable the CSP header:
 | 
	
		
			
				|  |  |  [source,java,role="primary"]
 | 
	
		
			
				|  |  |  ----
 | 
	
		
			
				|  |  |  @EnableWebSecurity
 | 
	
		
			
				|  |  | -public class WebSecurityConfig extends
 | 
	
		
			
				|  |  | -WebSecurityConfigurerAdapter {
 | 
	
		
			
				|  |  | +public class WebSecurityConfig {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	@Override
 | 
	
		
			
				|  |  | -	protected void configure(HttpSecurity http) {
 | 
	
		
			
				|  |  | +	@Bean
 | 
	
		
			
				|  |  | +	public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
 | 
	
		
			
				|  |  |  		http
 | 
	
		
			
				|  |  |  			// ...
 | 
	
		
			
				|  |  |  			.headers(headers -> headers
 | 
	
	
		
			
				|  | @@ -593,6 +610,7 @@ WebSecurityConfigurerAdapter {
 | 
	
		
			
				|  |  |  					.policyDirectives("script-src 'self' https://trustedscripts.example.com; object-src https://trustedplugins.example.com; report-uri /csp-report-endpoint/")
 | 
	
		
			
				|  |  |  				)
 | 
	
		
			
				|  |  |  			);
 | 
	
		
			
				|  |  | +		return http.build();
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  ----
 | 
	
	
		
			
				|  | @@ -614,9 +632,10 @@ WebSecurityConfigurerAdapter {
 | 
	
		
			
				|  |  |  [source,kotlin,role="secondary"]
 | 
	
		
			
				|  |  |  ----
 | 
	
		
			
				|  |  |  @EnableWebSecurity
 | 
	
		
			
				|  |  | -class SecurityConfig : WebSecurityConfigurerAdapter() {
 | 
	
		
			
				|  |  | +class SecurityConfig {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    override fun configure(http: HttpSecurity) {
 | 
	
		
			
				|  |  | +    @Bean
 | 
	
		
			
				|  |  | +    open fun filterChain(http: HttpSecurity): SecurityFilterChain {
 | 
	
		
			
				|  |  |          http {
 | 
	
		
			
				|  |  |              // ...
 | 
	
		
			
				|  |  |              headers {
 | 
	
	
		
			
				|  | @@ -625,6 +644,7 @@ class SecurityConfig : WebSecurityConfigurerAdapter() {
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +        return http.build()
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  ----
 | 
	
	
		
			
				|  | @@ -638,11 +658,10 @@ To enable the CSP `report-only` header, provide the following configuration:
 | 
	
		
			
				|  |  |  [source,java,role="primary"]
 | 
	
		
			
				|  |  |  ----
 | 
	
		
			
				|  |  |  @EnableWebSecurity
 | 
	
		
			
				|  |  | -public class WebSecurityConfig extends
 | 
	
		
			
				|  |  | -		WebSecurityConfigurerAdapter {
 | 
	
		
			
				|  |  | +public class WebSecurityConfig {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	@Override
 | 
	
		
			
				|  |  | -	protected void configure(HttpSecurity http) throws Exception {
 | 
	
		
			
				|  |  | +	@Bean
 | 
	
		
			
				|  |  | +	public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
 | 
	
		
			
				|  |  |  		http
 | 
	
		
			
				|  |  |  			// ...
 | 
	
		
			
				|  |  |  			.headers(headers -> headers
 | 
	
	
		
			
				|  | @@ -651,6 +670,7 @@ public class WebSecurityConfig extends
 | 
	
		
			
				|  |  |  					.reportOnly()
 | 
	
		
			
				|  |  |  				)
 | 
	
		
			
				|  |  |  			);
 | 
	
		
			
				|  |  | +		return http.build();
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  ----
 | 
	
	
		
			
				|  | @@ -673,9 +693,10 @@ public class WebSecurityConfig extends
 | 
	
		
			
				|  |  |  [source,kotlin,role="secondary"]
 | 
	
		
			
				|  |  |  ----
 | 
	
		
			
				|  |  |  @EnableWebSecurity
 | 
	
		
			
				|  |  | -class SecurityConfig : WebSecurityConfigurerAdapter() {
 | 
	
		
			
				|  |  | +class SecurityConfig {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    override fun configure(http: HttpSecurity) {
 | 
	
		
			
				|  |  | +    @Bean
 | 
	
		
			
				|  |  | +    open fun filterChain(http: HttpSecurity): SecurityFilterChain {
 | 
	
		
			
				|  |  |          http {
 | 
	
		
			
				|  |  |              // ...
 | 
	
		
			
				|  |  |              headers {
 | 
	
	
		
			
				|  | @@ -685,6 +706,7 @@ class SecurityConfig : WebSecurityConfigurerAdapter() {
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +        return http.build()
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  ----
 | 
	
	
		
			
				|  | @@ -702,11 +724,10 @@ You can enable the Referrer Policy header by using the configuration:
 | 
	
		
			
				|  |  |  [source,java,role="primary"]
 | 
	
		
			
				|  |  |  ----
 | 
	
		
			
				|  |  |  @EnableWebSecurity
 | 
	
		
			
				|  |  | -public class WebSecurityConfig extends
 | 
	
		
			
				|  |  | -WebSecurityConfigurerAdapter {
 | 
	
		
			
				|  |  | +public class WebSecurityConfig {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	@Override
 | 
	
		
			
				|  |  | -	protected void configure(HttpSecurity http) {
 | 
	
		
			
				|  |  | +	@Bean
 | 
	
		
			
				|  |  | +	public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
 | 
	
		
			
				|  |  |  		http
 | 
	
		
			
				|  |  |  			// ...
 | 
	
		
			
				|  |  |  			.headers(headers -> headers
 | 
	
	
		
			
				|  | @@ -714,6 +735,7 @@ WebSecurityConfigurerAdapter {
 | 
	
		
			
				|  |  |  					.policy(ReferrerPolicy.SAME_ORIGIN)
 | 
	
		
			
				|  |  |  				)
 | 
	
		
			
				|  |  |  			);
 | 
	
		
			
				|  |  | +		return http.build();
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  ----
 | 
	
	
		
			
				|  | @@ -734,9 +756,10 @@ WebSecurityConfigurerAdapter {
 | 
	
		
			
				|  |  |  [source,kotlin,role="secondary"]
 | 
	
		
			
				|  |  |  ----
 | 
	
		
			
				|  |  |  @EnableWebSecurity
 | 
	
		
			
				|  |  | -class SecurityConfig : WebSecurityConfigurerAdapter() {
 | 
	
		
			
				|  |  | +class SecurityConfig {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    override fun configure(http: HttpSecurity) {
 | 
	
		
			
				|  |  | +    @Bean
 | 
	
		
			
				|  |  | +    open fun filterChain(http: HttpSecurity): SecurityFilterChain {
 | 
	
		
			
				|  |  |          http {
 | 
	
		
			
				|  |  |              // ...
 | 
	
		
			
				|  |  |              headers {
 | 
	
	
		
			
				|  | @@ -745,6 +768,7 @@ class SecurityConfig : WebSecurityConfigurerAdapter() {
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +        return http.build()
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  ----
 | 
	
	
		
			
				|  | @@ -772,16 +796,16 @@ You can enable the preceding feature policy header by using the following config
 | 
	
		
			
				|  |  |  [source,java,role="primary"]
 | 
	
		
			
				|  |  |  ----
 | 
	
		
			
				|  |  |  @EnableWebSecurity
 | 
	
		
			
				|  |  | -public class WebSecurityConfig extends
 | 
	
		
			
				|  |  | -WebSecurityConfigurerAdapter {
 | 
	
		
			
				|  |  | +public class WebSecurityConfig {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	@Override
 | 
	
		
			
				|  |  | -	protected void configure(HttpSecurity http) throws Exception {
 | 
	
		
			
				|  |  | +	@Bean
 | 
	
		
			
				|  |  | +	public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
 | 
	
		
			
				|  |  |  		http
 | 
	
		
			
				|  |  |  			// ...
 | 
	
		
			
				|  |  |  			.headers(headers -> headers
 | 
	
		
			
				|  |  |  				.featurePolicy("geolocation 'self'")
 | 
	
		
			
				|  |  |  			);
 | 
	
		
			
				|  |  | +		return http.build();
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  ----
 | 
	
	
		
			
				|  | @@ -802,15 +826,17 @@ WebSecurityConfigurerAdapter {
 | 
	
		
			
				|  |  |  [source,kotlin,role="secondary"]
 | 
	
		
			
				|  |  |  ----
 | 
	
		
			
				|  |  |  @EnableWebSecurity
 | 
	
		
			
				|  |  | -class SecurityConfig : WebSecurityConfigurerAdapter() {
 | 
	
		
			
				|  |  | +class SecurityConfig {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    override fun configure(http: HttpSecurity) {
 | 
	
		
			
				|  |  | +    @Bean
 | 
	
		
			
				|  |  | +    open fun filterChain(http: HttpSecurity): SecurityFilterChain {
 | 
	
		
			
				|  |  |          http {
 | 
	
		
			
				|  |  |              // ...
 | 
	
		
			
				|  |  |              headers {
 | 
	
		
			
				|  |  |                  featurePolicy("geolocation 'self'")
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +        return http.build()
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  ----
 | 
	
	
		
			
				|  | @@ -838,11 +864,10 @@ You can enable the preceding permissions policy header using the following confi
 | 
	
		
			
				|  |  |  [source,java,role="primary"]
 | 
	
		
			
				|  |  |  ----
 | 
	
		
			
				|  |  |  @EnableWebSecurity
 | 
	
		
			
				|  |  | -public class WebSecurityConfig extends
 | 
	
		
			
				|  |  | -WebSecurityConfigurerAdapter {
 | 
	
		
			
				|  |  | +public class WebSecurityConfig {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	@Override
 | 
	
		
			
				|  |  | -	protected void configure(HttpSecurity http) throws Exception {
 | 
	
		
			
				|  |  | +	@Bean
 | 
	
		
			
				|  |  | +	public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
 | 
	
		
			
				|  |  |  		http
 | 
	
		
			
				|  |  |  			// ...
 | 
	
		
			
				|  |  |  			.headers(headers -> headers
 | 
	
	
		
			
				|  | @@ -850,6 +875,7 @@ WebSecurityConfigurerAdapter {
 | 
	
		
			
				|  |  |  					.policy("geolocation=(self)")
 | 
	
		
			
				|  |  |  				)
 | 
	
		
			
				|  |  |  			);
 | 
	
		
			
				|  |  | +		return http.build();
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  ----
 | 
	
	
		
			
				|  | @@ -870,9 +896,10 @@ WebSecurityConfigurerAdapter {
 | 
	
		
			
				|  |  |  [source,kotlin,role="secondary"]
 | 
	
		
			
				|  |  |  ----
 | 
	
		
			
				|  |  |  @EnableWebSecurity
 | 
	
		
			
				|  |  | -class SecurityConfig : WebSecurityConfigurerAdapter() {
 | 
	
		
			
				|  |  | +class SecurityConfig {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    override fun configure(http: HttpSecurity) {
 | 
	
		
			
				|  |  | +    @Bean
 | 
	
		
			
				|  |  | +    open fun filterChain(http: HttpSecurity): SecurityFilterChain {
 | 
	
		
			
				|  |  |          http {
 | 
	
		
			
				|  |  |              // ...
 | 
	
		
			
				|  |  |              headers {
 | 
	
	
		
			
				|  | @@ -881,6 +908,7 @@ class SecurityConfig : WebSecurityConfigurerAdapter() {
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +        return http.build()
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  ----
 | 
	
	
		
			
				|  | @@ -907,16 +935,16 @@ You can send the preceding header on log out with the following configuration:
 | 
	
		
			
				|  |  |  [source,java,role="primary"]
 | 
	
		
			
				|  |  |  ----
 | 
	
		
			
				|  |  |  @EnableWebSecurity
 | 
	
		
			
				|  |  | -public class WebSecurityConfig extends
 | 
	
		
			
				|  |  | -WebSecurityConfigurerAdapter {
 | 
	
		
			
				|  |  | +public class WebSecurityConfig {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	@Override
 | 
	
		
			
				|  |  | -	protected void configure(HttpSecurity http) throws Exception {
 | 
	
		
			
				|  |  | +	@Bean
 | 
	
		
			
				|  |  | +	public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
 | 
	
		
			
				|  |  |  		http
 | 
	
		
			
				|  |  |  			// ...
 | 
	
		
			
				|  |  |  			.logout((logout) -> logout
 | 
	
		
			
				|  |  |                  .addLogoutHandler(new HeaderWriterLogoutHandler(new ClearSiteDataHeaderWriter(CACHE, COOKIES)))
 | 
	
		
			
				|  |  |  			);
 | 
	
		
			
				|  |  | +		return http.build();
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  ----
 | 
	
	
		
			
				|  | @@ -925,15 +953,17 @@ WebSecurityConfigurerAdapter {
 | 
	
		
			
				|  |  |  [source,kotlin,role="secondary"]
 | 
	
		
			
				|  |  |  ----
 | 
	
		
			
				|  |  |  @EnableWebSecurity
 | 
	
		
			
				|  |  | -class SecurityConfig : WebSecurityConfigurerAdapter() {
 | 
	
		
			
				|  |  | +class SecurityConfig {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    override fun configure(http: HttpSecurity) {
 | 
	
		
			
				|  |  | +    @Bean
 | 
	
		
			
				|  |  | +    open fun filterChain(http: HttpSecurity): SecurityFilterChain {
 | 
	
		
			
				|  |  |          http {
 | 
	
		
			
				|  |  |              // ...
 | 
	
		
			
				|  |  |              logout {
 | 
	
		
			
				|  |  |                  addLogoutHandler(HeaderWriterLogoutHandler(ClearSiteDataHeaderWriter(CACHE, COOKIES)))
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +        return http.build()
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  ----
 | 
	
	
		
			
				|  | @@ -962,16 +992,16 @@ Given the preceding header, you could add the headers to the response by using t
 | 
	
		
			
				|  |  |  [source,java,role="primary"]
 | 
	
		
			
				|  |  |  ----
 | 
	
		
			
				|  |  |  @EnableWebSecurity
 | 
	
		
			
				|  |  | -public class WebSecurityConfig extends
 | 
	
		
			
				|  |  | -WebSecurityConfigurerAdapter {
 | 
	
		
			
				|  |  | +public class WebSecurityConfig {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	@Override
 | 
	
		
			
				|  |  | -	protected void configure(HttpSecurity http) throws Exception {
 | 
	
		
			
				|  |  | +	@Bean
 | 
	
		
			
				|  |  | +	public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
 | 
	
		
			
				|  |  |  		http
 | 
	
		
			
				|  |  |  			// ...
 | 
	
		
			
				|  |  |  			.headers(headers -> headers
 | 
	
		
			
				|  |  |  				.addHeaderWriter(new StaticHeadersWriter("X-Custom-Security-Header","header-value"))
 | 
	
		
			
				|  |  |  			);
 | 
	
		
			
				|  |  | +		return http.build();
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  ----
 | 
	
	
		
			
				|  | @@ -992,15 +1022,17 @@ WebSecurityConfigurerAdapter {
 | 
	
		
			
				|  |  |  [source,kotlin,role="secondary"]
 | 
	
		
			
				|  |  |  ----
 | 
	
		
			
				|  |  |  @EnableWebSecurity
 | 
	
		
			
				|  |  | -class SecurityConfig : WebSecurityConfigurerAdapter() {
 | 
	
		
			
				|  |  | +class SecurityConfig {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    override fun configure(http: HttpSecurity) {
 | 
	
		
			
				|  |  | +    @Bean
 | 
	
		
			
				|  |  | +    open fun filterChain(http: HttpSecurity): SecurityFilterChain {
 | 
	
		
			
				|  |  |          http {
 | 
	
		
			
				|  |  |              // ...
 | 
	
		
			
				|  |  |              headers {
 | 
	
		
			
				|  |  |                  addHeaderWriter(StaticHeadersWriter("X-Custom-Security-Header","header-value"))
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +        return http.build()
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  ----
 | 
	
	
		
			
				|  | @@ -1019,16 +1051,16 @@ If you wanted to explicitly configure <<servlet-headers-frame-options>>, you cou
 | 
	
		
			
				|  |  |  [source,java,role="primary"]
 | 
	
		
			
				|  |  |  ----
 | 
	
		
			
				|  |  |  @EnableWebSecurity
 | 
	
		
			
				|  |  | -public class WebSecurityConfig extends
 | 
	
		
			
				|  |  | -WebSecurityConfigurerAdapter {
 | 
	
		
			
				|  |  | +public class WebSecurityConfig {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	@Override
 | 
	
		
			
				|  |  | -	protected void configure(HttpSecurity http) throws Exception {
 | 
	
		
			
				|  |  | +	@Bean
 | 
	
		
			
				|  |  | +	public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
 | 
	
		
			
				|  |  |  		http
 | 
	
		
			
				|  |  |  			// ...
 | 
	
		
			
				|  |  |  			.headers(headers -> headers
 | 
	
		
			
				|  |  |  				.addHeaderWriter(new XFrameOptionsHeaderWriter(XFrameOptionsMode.SAMEORIGIN))
 | 
	
		
			
				|  |  |  			);
 | 
	
		
			
				|  |  | +		return http.build();
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  ----
 | 
	
	
		
			
				|  | @@ -1055,15 +1087,17 @@ See https://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsi
 | 
	
		
			
				|  |  |  [source,kotlin,role="secondary"]
 | 
	
		
			
				|  |  |  ----
 | 
	
		
			
				|  |  |  @EnableWebSecurity
 | 
	
		
			
				|  |  | -class SecurityConfig : WebSecurityConfigurerAdapter() {
 | 
	
		
			
				|  |  | +class SecurityConfig {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    override fun configure(http: HttpSecurity) {
 | 
	
		
			
				|  |  | +    @Bean
 | 
	
		
			
				|  |  | +    open fun filterChain(http: HttpSecurity): SecurityFilterChain {
 | 
	
		
			
				|  |  |          http {
 | 
	
		
			
				|  |  |              // ...
 | 
	
		
			
				|  |  |              headers {
 | 
	
		
			
				|  |  |                  addHeaderWriter(XFrameOptionsHeaderWriter(XFrameOptionsMode.SAMEORIGIN))
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +        return http.build()
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  ----
 | 
	
	
		
			
				|  | @@ -1084,11 +1118,10 @@ The following configuration example uses `DelegatingRequestMatcherHeaderWriter`:
 | 
	
		
			
				|  |  |  [source,java,role="primary"]
 | 
	
		
			
				|  |  |  ----
 | 
	
		
			
				|  |  |  @EnableWebSecurity
 | 
	
		
			
				|  |  | -public class WebSecurityConfig extends
 | 
	
		
			
				|  |  | -WebSecurityConfigurerAdapter {
 | 
	
		
			
				|  |  | +public class WebSecurityConfig {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	@Override
 | 
	
		
			
				|  |  | -	protected void configure(HttpSecurity http) throws Exception {
 | 
	
		
			
				|  |  | +	@Bean
 | 
	
		
			
				|  |  | +	public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
 | 
	
		
			
				|  |  |  		RequestMatcher matcher = new AntPathRequestMatcher("/login");
 | 
	
		
			
				|  |  |  		DelegatingRequestMatcherHeaderWriter headerWriter =
 | 
	
		
			
				|  |  |  			new DelegatingRequestMatcherHeaderWriter(matcher,new XFrameOptionsHeaderWriter());
 | 
	
	
		
			
				|  | @@ -1098,6 +1131,7 @@ WebSecurityConfigurerAdapter {
 | 
	
		
			
				|  |  |  				.frameOptions(frameOptions -> frameOptions.disable())
 | 
	
		
			
				|  |  |  				.addHeaderWriter(headerWriter)
 | 
	
		
			
				|  |  |  			);
 | 
	
		
			
				|  |  | +		return http.build();
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  ----
 | 
	
	
		
			
				|  | @@ -1131,9 +1165,10 @@ WebSecurityConfigurerAdapter {
 | 
	
		
			
				|  |  |  [source,kotlin,role="secondary"]
 | 
	
		
			
				|  |  |  ----
 | 
	
		
			
				|  |  |  @EnableWebSecurity
 | 
	
		
			
				|  |  | -class SecurityConfig : WebSecurityConfigurerAdapter() {
 | 
	
		
			
				|  |  | +class SecurityConfig {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    override fun configure(http: HttpSecurity) {
 | 
	
		
			
				|  |  | +    @Bean
 | 
	
		
			
				|  |  | +    open fun filterChain(http: HttpSecurity): SecurityFilterChain {
 | 
	
		
			
				|  |  |          val matcher: RequestMatcher = AntPathRequestMatcher("/login")
 | 
	
		
			
				|  |  |          val headerWriter = DelegatingRequestMatcherHeaderWriter(matcher, XFrameOptionsHeaderWriter())
 | 
	
		
			
				|  |  |         http {
 | 
	
	
		
			
				|  | @@ -1144,6 +1179,7 @@ class SecurityConfig : WebSecurityConfigurerAdapter() {
 | 
	
		
			
				|  |  |                  addHeaderWriter(headerWriter)
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +        return http.build()
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  ----
 |