From db79faf569ce807cea2d7970f5347ba234acbdbe Mon Sep 17 00:00:00 2001 From: anuragkumawat Date: Tue, 20 Sep 2022 20:00:27 +0530 Subject: [PATCH] JAVA-14679 Update spring-boot-bootstrap module under spring-boot-modules to remove usage of deprecated WebSecurityConfigurerAdapter --- .../java/com/baeldung/config/SecurityConfig.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/spring-boot-modules/spring-boot-bootstrap/src/main/java/com/baeldung/config/SecurityConfig.java b/spring-boot-modules/spring-boot-bootstrap/src/main/java/com/baeldung/config/SecurityConfig.java index 8e403f3976..ecb21cdf4b 100644 --- a/spring-boot-modules/spring-boot-bootstrap/src/main/java/com/baeldung/config/SecurityConfig.java +++ b/spring-boot-modules/spring-boot-bootstrap/src/main/java/com/baeldung/config/SecurityConfig.java @@ -1,20 +1,23 @@ package com.baeldung.config; +import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; +import org.springframework.security.web.SecurityFilterChain; @Configuration @EnableWebSecurity -public class SecurityConfig extends WebSecurityConfigurerAdapter { +public class SecurityConfig { - @Override - protected void configure(HttpSecurity http) throws Exception { + @Bean + public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { http.authorizeRequests() .anyRequest() .permitAll() - .and().csrf().disable(); + .and() + .csrf() + .disable(); + return http.build(); } - }