From d5dab3836e55205f42764c3eb36246aea1bbdab4 Mon Sep 17 00:00:00 2001 From: Wim Deblauwe Date: Wed, 18 Sep 2024 21:19:02 +0200 Subject: [PATCH] docs: Replace deprecated methods of Spring Security with new alternatives Fixes #100 --- src/docs/asciidoc/index.adoc | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/docs/asciidoc/index.adoc b/src/docs/asciidoc/index.adoc index 6286452..e4fa213 100644 --- a/src/docs/asciidoc/index.adoc +++ b/src/docs/asciidoc/index.adoc @@ -1212,8 +1212,10 @@ import io.github.wimdeblauwe.errorhandlingspringbootstarter.mapper.ErrorMessageM import io.github.wimdeblauwe.errorhandlingspringbootstarter.mapper.HttpStatusMapper; import org.springframework.context.annotation.Bean; +import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer; import org.springframework.security.web.SecurityFilterChain; import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer; public class WebSecurityConfiguration { @Bean @@ -1227,11 +1229,11 @@ public class WebSecurityConfiguration { @Bean public SecurityFilterChain securityFilterChain(HttpSecurity http, UnauthorizedEntryPoint unauthorizedEntryPoint) throws Exception { - http.httpBasic().disable(); + http.httpBasic(AbstractHttpConfigurer::disable); - http.authorizeHttpRequests().anyRequest().authenticated(); + http.authorizeHttpRequests(customizer -> customizer.anyRequest().authenticated()); - http.exceptionHandling().authenticationEntryPoint(unauthorizedEntryPoint);//<.> + http.exceptionHandling(customizer -> customizer.authenticationEntryPoint(unauthorizedEntryPoint));//<.> return http.build(); } @@ -1258,6 +1260,7 @@ import io.github.wimdeblauwe.errorhandlingspringbootstarter.mapper.HttpStatusMap import org.springframework.context.annotation.Bean; import org.springframework.security.web.SecurityFilterChain; import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer; public class WebSecurityConfiguration { @@ -1272,11 +1275,11 @@ public class WebSecurityConfiguration { @Bean public SecurityFilterChain securityFilterChain(HttpSecurity http, AccessDeniedHandler accessDeniedHandler) throws Exception { - http.httpBasic().disable(); + http.httpBasic(AbstractHttpConfigurer::disable); - http.authorizeHttpRequests().anyRequest().authenticated(); + http.authorizeHttpRequests(customizer -> customizer.anyRequest().authenticated()); - http.exceptionHandling().accessDeniedHandler(accessDeniedHandler);//<.> + http.exceptionHandling(customizer -> customizer.accessDeniedHandler(accessDeniedHandler));//<.> return http.build(); }