From a3a852512374550750dd29f54845db13a4be12b8 Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Thu, 21 Nov 2024 16:04:05 -0300 Subject: [PATCH] spring-boot: revert v3.3.5 workarounds (#27961) --- .../SecurityConfiguration_imperative.java.ejs | 24 ------------------- .../SecurityConfiguration_reactive.java.ejs | 24 ------------------- 2 files changed, 48 deletions(-) diff --git a/generators/spring-boot/templates/src/main/java/_package_/config/SecurityConfiguration_imperative.java.ejs b/generators/spring-boot/templates/src/main/java/_package_/config/SecurityConfiguration_imperative.java.ejs index 0fca34168b5d..2608def03185 100644 --- a/generators/spring-boot/templates/src/main/java/_package_/config/SecurityConfiguration_imperative.java.ejs +++ b/generators/spring-boot/templates/src/main/java/_package_/config/SecurityConfiguration_imperative.java.ejs @@ -51,10 +51,6 @@ import tech.jhipster.web.filter.CookieCsrfFilter; <%_ if (!skipClient) { _%> import <%= packageName %>.web.filter.SpaWebFilter; <%_ } _%> -<%_ if (applicationTypeGateway) { _%> -import org.springframework.beans.BeansException; -import org.springframework.beans.factory.config.BeanPostProcessor; -<%_ } _%> <%_ if (authenticationUsesCsrf && !applicationTypeMicroservice) { _%> import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; @@ -117,10 +113,6 @@ import <%= packageName %>.security.oauth2.CustomClaimConverter; <%_ if(!skipClient) { _%> import org.springframework.security.web.header.writers.ReferrerPolicyHeaderWriter; <%_ } _%> -<%_ if (applicationTypeGateway) { _%> -import org.springframework.security.web.server.WebFilterChainProxy; -import org.springframework.security.web.server.firewall.ServerWebExchangeFirewall; -<%_ } _%> <%_ if (authenticationUsesCsrf && !applicationTypeMicroservice) { _%> import org.springframework.util.StringUtils; <%_ } _%> @@ -424,20 +416,4 @@ public class SecurityConfiguration { } } <%_ } _%> -<%_ if (applicationTypeGateway) { _%> - - // Fix for Spring Boot 3.3.5: https://github.com/spring-cloud/spring-cloud-gateway/issues/3568 - @Bean - BeanPostProcessor beanPostProcessor() { - return new BeanPostProcessor() { - @Override - public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { - if (bean instanceof WebFilterChainProxy springSecurity) { - springSecurity.setFirewall(ServerWebExchangeFirewall.INSECURE_NOOP); - } - return bean; - } - }; - } -<%_ } _%> } diff --git a/generators/spring-boot/templates/src/main/java/_package_/config/SecurityConfiguration_reactive.java.ejs b/generators/spring-boot/templates/src/main/java/_package_/config/SecurityConfiguration_reactive.java.ejs index f5424a90b626..ea732caf90c1 100644 --- a/generators/spring-boot/templates/src/main/java/_package_/config/SecurityConfiguration_reactive.java.ejs +++ b/generators/spring-boot/templates/src/main/java/_package_/config/SecurityConfiguration_reactive.java.ejs @@ -39,10 +39,6 @@ import org.springframework.boot.autoconfigure.security.SecurityProperties; <%_ if (!skipClient) { _%> import <%= packageName %>.web.filter.SpaWebFilter; <%_ } _%> -<%_ if (applicationTypeGateway) { _%> -import org.springframework.beans.BeansException; -import org.springframework.beans.factory.config.BeanPostProcessor; -<%_ } _%> import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; <%_ if (authenticationTypeOauth2) { _%> @@ -118,10 +114,6 @@ import org.springframework.security.web.server.savedrequest.NoOpServerRequestCac <%_ } _%> import org.springframework.security.web.server.util.matcher.NegatedServerWebExchangeMatcher; import org.springframework.security.web.server.util.matcher.OrServerWebExchangeMatcher; -<%_ if (applicationTypeGateway) { _%> -import org.springframework.security.web.server.WebFilterChainProxy; -import org.springframework.security.web.server.firewall.ServerWebExchangeFirewall; -<%_ } _%> <%_ if (authenticationUsesCsrf) { _%> import reactor.core.publisher.Mono; <%_ } _%> @@ -490,20 +482,4 @@ public class SecurityConfiguration { return Mono.empty(); } <%_ } _%> -<%_ if (applicationTypeGateway) { _%> - - // Fix for Spring Boot 3.3.5: https://github.com/spring-cloud/spring-cloud-gateway/issues/3568 - @Bean - BeanPostProcessor beanPostProcessor() { - return new BeanPostProcessor() { - @Override - public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { - if (bean instanceof WebFilterChainProxy springSecurity) { - springSecurity.setFirewall(ServerWebExchangeFirewall.INSECURE_NOOP); - } - return bean; - } - }; - } -<%_ } _%> }