diff --git a/pom.xml b/pom.xml index baf7b7300f..9fa86a71f8 100644 --- a/pom.xml +++ b/pom.xml @@ -805,6 +805,7 @@ spring-cloud-modules/spring-cloud-security spring-cloud-modules/spring-cloud-zuul-eureka-integration + spring-cloud-modules/spring-cloud-bootstrap spring-core-2 spring-core-3 spring-core-4 @@ -1052,6 +1053,7 @@ spring-cloud-modules/spring-cloud-security spring-cloud-modules/spring-cloud-zuul-eureka-integration + spring-cloud-modules/spring-cloud-bootstrap spring-core-2 spring-core-3 spring-core-4 diff --git a/spring-cloud-modules/pom.xml b/spring-cloud-modules/pom.xml index 2613b9f9ce..187958fa6c 100644 --- a/spring-cloud-modules/pom.xml +++ b/spring-cloud-modules/pom.xml @@ -22,7 +22,8 @@ spring-cloud-hystrix - spring-cloud-bootstrap + + spring-cloud-ribbon-client spring-cloud-zookeeper spring-cloud-gateway diff --git a/spring-cloud-modules/spring-cloud-bootstrap/config/pom.xml b/spring-cloud-modules/spring-cloud-bootstrap/config/pom.xml index c1be447822..4831759fef 100644 --- a/spring-cloud-modules/spring-cloud-bootstrap/config/pom.xml +++ b/spring-cloud-modules/spring-cloud-bootstrap/config/pom.xml @@ -9,9 +9,9 @@ com.baeldung - parent-boot-2 + parent-boot-3 0.0.1-SNAPSHOT - ../../../parent-boot-2 + ../../../parent-boot-3 @@ -42,7 +42,7 @@ - 2021.0.7 + 2022.0.4 \ No newline at end of file diff --git a/spring-cloud-modules/spring-cloud-bootstrap/customer-service/pom.xml b/spring-cloud-modules/spring-cloud-bootstrap/customer-service/pom.xml index da2dee97d5..c4d31138ad 100644 --- a/spring-cloud-modules/spring-cloud-bootstrap/customer-service/pom.xml +++ b/spring-cloud-modules/spring-cloud-bootstrap/customer-service/pom.xml @@ -11,9 +11,9 @@ com.baeldung - parent-boot-2 + parent-boot-3 0.0.1-SNAPSHOT - ../../../parent-boot-2 + ../../../parent-boot-3 diff --git a/spring-cloud-modules/spring-cloud-bootstrap/discovery/pom.xml b/spring-cloud-modules/spring-cloud-bootstrap/discovery/pom.xml index 28c1a741a6..0527a232f7 100644 --- a/spring-cloud-modules/spring-cloud-bootstrap/discovery/pom.xml +++ b/spring-cloud-modules/spring-cloud-bootstrap/discovery/pom.xml @@ -9,9 +9,9 @@ com.baeldung - parent-boot-2 + parent-boot-3 0.0.1-SNAPSHOT - ../../../parent-boot-2 + ../../../parent-boot-3 @@ -54,7 +54,7 @@ - 2021.0.7 + 2022.0.3 \ No newline at end of file diff --git a/spring-cloud-modules/spring-cloud-bootstrap/discovery/src/main/java/com/baeldung/spring/cloud/bootstrap/discovery/SecurityConfig.java b/spring-cloud-modules/spring-cloud-bootstrap/discovery/src/main/java/com/baeldung/spring/cloud/bootstrap/discovery/SecurityConfig.java index fa389ec6a3..b30515cdcf 100644 --- a/spring-cloud-modules/spring-cloud-bootstrap/discovery/src/main/java/com/baeldung/spring/cloud/bootstrap/discovery/SecurityConfig.java +++ b/spring-cloud-modules/spring-cloud-bootstrap/discovery/src/main/java/com/baeldung/spring/cloud/bootstrap/discovery/SecurityConfig.java @@ -4,41 +4,38 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Configuration; import org.springframework.core.annotation.Order; import org.springframework.http.HttpMethod; +import org.springframework.security.config.Customizer; import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; 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.config.http.SessionCreationPolicy; @Configuration @EnableWebSecurity @Order(1) -public class SecurityConfig extends WebSecurityConfigurerAdapter { +public class SecurityConfig { @Autowired public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { auth.inMemoryAuthentication().withUser("discUser").password("{noop}discPassword").roles("SYSTEM"); } - @Override protected void configure(HttpSecurity http) throws Exception { - http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.ALWAYS).and().requestMatchers().antMatchers("/eureka/**").and().authorizeRequests().antMatchers("/eureka/**").hasRole("SYSTEM").anyRequest().denyAll().and().httpBasic().and().csrf() - .disable(); + http.sessionManagement(session -> session.sessionCreationPolicy(SessionCreationPolicy.ALWAYS)).authorizeHttpRequests(auth -> auth.requestMatchers("/eureka/**")).authorizeRequests(auth -> auth.requestMatchers("/eureka/**").hasRole("SYSTEM").anyRequest().denyAll()).httpBasic( + Customizer.withDefaults()).csrf(csrf -> csrf.disable()); } @Configuration // no order tag means this is the last security filter to be evaluated - public static class AdminSecurityConfig extends WebSecurityConfigurerAdapter { + public static class AdminSecurityConfig { - @Autowired public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { auth.inMemoryAuthentication(); } - @Override protected void configure(HttpSecurity http) throws Exception { - http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.NEVER).and().httpBasic().disable().authorizeRequests().antMatchers(HttpMethod.GET, "/").hasRole("ADMIN").antMatchers("/info", "/health").authenticated().anyRequest().denyAll() - .and().csrf().disable(); + http.sessionManagement(session -> session.sessionCreationPolicy(SessionCreationPolicy.NEVER)).httpBasic(basic -> basic.disable()).authorizeRequests().requestMatchers(HttpMethod.GET, "/").hasRole("ADMIN").requestMatchers("/info", "/health").authenticated().anyRequest().denyAll() + .and().csrf(csrf -> csrf.disable()); } } } diff --git a/spring-cloud-modules/spring-cloud-bootstrap/gateway/pom.xml b/spring-cloud-modules/spring-cloud-bootstrap/gateway/pom.xml index fa6735199f..b29d2eb760 100644 --- a/spring-cloud-modules/spring-cloud-bootstrap/gateway/pom.xml +++ b/spring-cloud-modules/spring-cloud-bootstrap/gateway/pom.xml @@ -9,9 +9,9 @@ com.baeldung - parent-boot-2 + parent-boot-3 0.0.1-SNAPSHOT - ../../../parent-boot-2 + ../../../parent-boot-3 @@ -55,18 +55,16 @@ org.springframework.boot spring-boot-starter-data-redis - - org.springframework.cloud - spring-cloud-starter-sleuth - - - org.springframework.cloud - spring-cloud-sleuth-zipkin - org.springframework.cloud spring-cloud-starter-openfeign + + io.rest-assured + rest-assured + ${rest-assured.version} + test + @@ -105,7 +103,8 @@ - 2021.0.7 + 2022.0.4 + 5.4.0 \ No newline at end of file diff --git a/spring-cloud-modules/spring-cloud-bootstrap/order-service/order-server/pom.xml b/spring-cloud-modules/spring-cloud-bootstrap/order-service/order-server/pom.xml index 85143b557e..e565a7dcab 100644 --- a/spring-cloud-modules/spring-cloud-bootstrap/order-service/order-server/pom.xml +++ b/spring-cloud-modules/spring-cloud-bootstrap/order-service/order-server/pom.xml @@ -20,6 +20,16 @@ 1.0.0-SNAPSHOT compile + + org.projectlombok + lombok + ${lombok.version} + provided + + + 1.18.30 + + \ No newline at end of file diff --git a/spring-cloud-modules/spring-cloud-bootstrap/order-service/pom.xml b/spring-cloud-modules/spring-cloud-bootstrap/order-service/pom.xml index 16366f5eb6..9adfbb4f54 100644 --- a/spring-cloud-modules/spring-cloud-bootstrap/order-service/pom.xml +++ b/spring-cloud-modules/spring-cloud-bootstrap/order-service/pom.xml @@ -11,9 +11,9 @@ com.baeldung - parent-boot-2 + parent-boot-3 0.0.1-SNAPSHOT - ../../../parent-boot-2 + ../../../parent-boot-3 @@ -81,16 +81,6 @@ exec - - start-application - - com.baeldung.orderservice.OrderApplication - ../order-server/target/classes - - - start - - @@ -116,6 +106,7 @@ 1.8 1.8 com.baeldung.orderservice.OrderApplication + true \ No newline at end of file diff --git a/spring-cloud-modules/spring-cloud-bootstrap/pom.xml b/spring-cloud-modules/spring-cloud-bootstrap/pom.xml index 73b07c826f..746b6f0405 100644 --- a/spring-cloud-modules/spring-cloud-bootstrap/pom.xml +++ b/spring-cloud-modules/spring-cloud-bootstrap/pom.xml @@ -25,4 +25,8 @@ order-service + + 17 + + \ No newline at end of file diff --git a/spring-cloud-modules/spring-cloud-bootstrap/zipkin-log-svc-book/pom.xml b/spring-cloud-modules/spring-cloud-bootstrap/zipkin-log-svc-book/pom.xml index 2a6196b92b..5fd97d0574 100644 --- a/spring-cloud-modules/spring-cloud-bootstrap/zipkin-log-svc-book/pom.xml +++ b/spring-cloud-modules/spring-cloud-bootstrap/zipkin-log-svc-book/pom.xml @@ -10,9 +10,9 @@ com.baeldung - parent-boot-2 + parent-boot-3 0.0.1-SNAPSHOT - ../../../parent-boot-2 + ../../../parent-boot-3 @@ -65,18 +65,10 @@ h2 runtime - - org.springframework.cloud - spring-cloud-starter-sleuth - - - org.springframework.cloud - spring-cloud-sleuth-zipkin - - 2021.0.7 + 2022.0.3 \ No newline at end of file diff --git a/spring-cloud-modules/spring-cloud-bootstrap/zipkin-log-svc-book/src/main/java/com/baeldung/spring/cloud/bootstrap/svcbook/SecurityConfig.java b/spring-cloud-modules/spring-cloud-bootstrap/zipkin-log-svc-book/src/main/java/com/baeldung/spring/cloud/bootstrap/svcbook/SecurityConfig.java index 0b9520c976..054eca5cfe 100644 --- a/spring-cloud-modules/spring-cloud-bootstrap/zipkin-log-svc-book/src/main/java/com/baeldung/spring/cloud/bootstrap/svcbook/SecurityConfig.java +++ b/spring-cloud-modules/spring-cloud-bootstrap/zipkin-log-svc-book/src/main/java/com/baeldung/spring/cloud/bootstrap/svcbook/SecurityConfig.java @@ -20,18 +20,17 @@ public class SecurityConfig { @Bean public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { - return http.authorizeHttpRequests((auth) -> auth.antMatchers(HttpMethod.GET, "/books") + return http.authorizeHttpRequests((auth) -> auth.requestMatchers(HttpMethod.GET, "/books") .permitAll() - .antMatchers(HttpMethod.GET, "/books/*") + .requestMatchers(HttpMethod.GET, "/books/*") .permitAll() - .antMatchers(HttpMethod.POST, "/books") + .requestMatchers(HttpMethod.POST, "/books") .hasRole("ADMIN") - .antMatchers(HttpMethod.PATCH, "/books/*") + .requestMatchers(HttpMethod.PATCH, "/books/*") .hasRole("ADMIN") - .antMatchers(HttpMethod.DELETE, "/books/*") + .requestMatchers(HttpMethod.DELETE, "/books/*") .hasRole("ADMIN")) - .csrf() - .disable() + .csrf(csrf -> csrf.disable()) .build(); } } diff --git a/spring-cloud-modules/spring-cloud-bootstrap/zipkin-log-svc-book/src/main/java/com/baeldung/spring/cloud/bootstrap/svcbook/book/Book.java b/spring-cloud-modules/spring-cloud-bootstrap/zipkin-log-svc-book/src/main/java/com/baeldung/spring/cloud/bootstrap/svcbook/book/Book.java index f087967bab..f5e4e9b496 100644 --- a/spring-cloud-modules/spring-cloud-bootstrap/zipkin-log-svc-book/src/main/java/com/baeldung/spring/cloud/bootstrap/svcbook/book/Book.java +++ b/spring-cloud-modules/spring-cloud-bootstrap/zipkin-log-svc-book/src/main/java/com/baeldung/spring/cloud/bootstrap/svcbook/book/Book.java @@ -2,10 +2,10 @@ package com.baeldung.spring.cloud.bootstrap.svcbook.book; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; @Entity @JsonIgnoreProperties(ignoreUnknown = true) diff --git a/spring-cloud-modules/spring-cloud-bootstrap/zipkin-log-svc-rating/pom.xml b/spring-cloud-modules/spring-cloud-bootstrap/zipkin-log-svc-rating/pom.xml index 54572eeea2..2d5ea8369d 100644 --- a/spring-cloud-modules/spring-cloud-bootstrap/zipkin-log-svc-rating/pom.xml +++ b/spring-cloud-modules/spring-cloud-bootstrap/zipkin-log-svc-rating/pom.xml @@ -10,9 +10,9 @@ com.baeldung - parent-boot-2 + parent-boot-3 0.0.1-SNAPSHOT - ../../../parent-boot-2 + ../../../parent-boot-3 @@ -68,14 +68,6 @@ org.springframework.boot spring-boot-starter-actuator - - org.springframework.cloud - spring-cloud-starter-sleuth - - - org.springframework.cloud - spring-cloud-sleuth-zipkin - com.h2database h2 @@ -84,7 +76,7 @@ - 2021.0.7 + 2022.0.3 \ No newline at end of file diff --git a/spring-cloud-modules/spring-cloud-bootstrap/zipkin-log-svc-rating/src/main/java/com/baeldung/spring/cloud/bootstrap/svcrating/SecurityConfig.java b/spring-cloud-modules/spring-cloud-bootstrap/zipkin-log-svc-rating/src/main/java/com/baeldung/spring/cloud/bootstrap/svcrating/SecurityConfig.java index f470946e1d..4f32bbed98 100644 --- a/spring-cloud-modules/spring-cloud-bootstrap/zipkin-log-svc-rating/src/main/java/com/baeldung/spring/cloud/bootstrap/svcrating/SecurityConfig.java +++ b/spring-cloud-modules/spring-cloud-bootstrap/zipkin-log-svc-rating/src/main/java/com/baeldung/spring/cloud/bootstrap/svcrating/SecurityConfig.java @@ -3,6 +3,7 @@ package com.baeldung.spring.cloud.bootstrap.svcrating; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.http.HttpMethod; +import org.springframework.security.config.Customizer; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.core.userdetails.UserDetailsService; @@ -20,22 +21,20 @@ public class SecurityConfig { @Bean public SecurityFilterChain filterChain(HttpSecurity httpSecurity) throws Exception { - return httpSecurity.authorizeHttpRequests((auth) -> auth.regexMatchers("^/ratings\\?bookId.*$") + return httpSecurity.authorizeHttpRequests((auth) -> auth.requestMatchers("^/ratings\\?bookId.*$") .authenticated() - .antMatchers(HttpMethod.POST, "/ratings") + .requestMatchers(HttpMethod.POST, "/ratings") .authenticated() - .antMatchers(HttpMethod.PATCH, "/ratings/*") + .requestMatchers(HttpMethod.PATCH, "/ratings/*") .hasRole("ADMIN") - .antMatchers(HttpMethod.DELETE, "/ratings/*") + .requestMatchers(HttpMethod.DELETE, "/ratings/*") .hasRole("ADMIN") - .antMatchers(HttpMethod.GET, "/ratings") + .requestMatchers(HttpMethod.GET, "/ratings") .hasRole("ADMIN") .anyRequest() .authenticated()) - .httpBasic() - .and() - .csrf() - .disable() + .httpBasic(Customizer.withDefaults()) + .csrf(csrf -> csrf.disable()) .build(); } } diff --git a/spring-cloud-modules/spring-cloud-bootstrap/zipkin-log-svc-rating/src/main/java/com/baeldung/spring/cloud/bootstrap/svcrating/rating/Rating.java b/spring-cloud-modules/spring-cloud-bootstrap/zipkin-log-svc-rating/src/main/java/com/baeldung/spring/cloud/bootstrap/svcrating/rating/Rating.java index 2c7069926c..cbb49914e3 100644 --- a/spring-cloud-modules/spring-cloud-bootstrap/zipkin-log-svc-rating/src/main/java/com/baeldung/spring/cloud/bootstrap/svcrating/rating/Rating.java +++ b/spring-cloud-modules/spring-cloud-bootstrap/zipkin-log-svc-rating/src/main/java/com/baeldung/spring/cloud/bootstrap/svcrating/rating/Rating.java @@ -2,11 +2,11 @@ package com.baeldung.spring.cloud.bootstrap.svcrating.rating; import java.io.Serializable; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.Transient; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.Transient; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;