JAVA-31190: Preparation for migrating spring-boot-modules to version 3. (#15834)

This commit is contained in:
Harry9656
2024-02-27 02:49:02 +01:00
committed by GitHub
parent 74da22b9c4
commit aefd833c3b
190 changed files with 1052 additions and 832 deletions
@@ -6,7 +6,9 @@ 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.configurers.AbstractHttpConfigurer;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
import org.zalando.problem.spring.web.advice.security.SecurityProblemSupport;
@Configuration
@@ -19,16 +21,11 @@ public class SecurityConfiguration {
@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http.csrf()
.disable();
http.authorizeRequests()
.antMatchers("/")
.permitAll();
http.exceptionHandling()
.authenticationEntryPoint(problemSupport)
.accessDeniedHandler(problemSupport);
return http.build();
return http.csrf(AbstractHttpConfigurer::disable)
.authorizeHttpRequests(request -> request.requestMatchers(new AntPathRequestMatcher("/"))
.permitAll())
.exceptionHandling(exceptionHandling -> exceptionHandling.authenticationEntryPoint(problemSupport)
.accessDeniedHandler(problemSupport))
.build();
}
}
@@ -4,7 +4,9 @@ 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.configurers.AbstractHttpConfigurer;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
/**
* Because the POM imports Spring Security, we need a simple security
@@ -16,10 +18,9 @@ public class SecurityConfiguration {
@Bean
public SecurityFilterChain securityFilter(HttpSecurity http) throws Exception {
http.csrf().disable();
return http.authorizeRequests()
.antMatchers("/**")
.permitAll().and().build();
return http.csrf(AbstractHttpConfigurer::disable)
.authorizeHttpRequests(request -> request.requestMatchers(new AntPathRequestMatcher("/**"))
.permitAll())
.build();
}
}
@@ -1,7 +1,7 @@
package com.baeldung.ratelimiting.bucket4japp.interceptor;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
@@ -1,7 +1,7 @@
package com.baeldung.toggle;
import javax.persistence.Entity;
import javax.persistence.Id;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
@Entity
public class Employee {
@@ -1,6 +1,6 @@
package com.baeldung.toggle;
import javax.annotation.security.RolesAllowed;
import jakarta.annotation.security.RolesAllowed;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;