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