JAVA-14681 Update spring-boot-libraries module under spring-boot-modules to remove usage of deprecated WebSecurityConfigurerAdapter (#12725)

* JAVA-14681 Update spring-boot-libraries module under spring-boot-modules to remove usage of deprecated WebSecurityConfigurerAdapter

* JAVA-14681 Correct Java Formatting
This commit is contained in:
anuragkumawat 2022-09-18 10:19:53 +05:30 committed by GitHub
parent 859e91538a
commit 3a3021fe53
1 changed files with 9 additions and 6 deletions

View File

@ -1,25 +1,27 @@
package com.baeldung.boot.problem.configuration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
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;
import org.zalando.problem.spring.web.advice.security.SecurityProblemSupport;
@Configuration
@EnableWebSecurity
@Import(SecurityProblemSupport.class)
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
public class SecurityConfiguration {
@Autowired
private SecurityProblemSupport problemSupport;
@Override
protected void configure(HttpSecurity http) throws Exception {
http.csrf().disable();
@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http.csrf()
.disable();
http.authorizeRequests()
.antMatchers("/")
.permitAll();
@ -27,5 +29,6 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
http.exceptionHandling()
.authenticationEntryPoint(problemSupport)
.accessDeniedHandler(problemSupport);
return http.build();
}
}