From 40660aa7b5fdcf7a2c0492148d9f524553623c2b Mon Sep 17 00:00:00 2001 From: Colin DAMON Date: Sun, 23 Jul 2023 08:52:41 +0200 Subject: [PATCH] Spring boot upgrade --- .../resources/generator/dependencies/pom.xml | 2 +- .../SecurityConfiguration.java.mustache | 42 ++++++++++--------- .../SecurityConfiguration.java.mustache | 36 ++++++++-------- 3 files changed, 42 insertions(+), 38 deletions(-) diff --git a/src/main/resources/generator/dependencies/pom.xml b/src/main/resources/generator/dependencies/pom.xml index 9473169951..03df95b53f 100644 --- a/src/main/resources/generator/dependencies/pom.xml +++ b/src/main/resources/generator/dependencies/pom.xml @@ -17,7 +17,7 @@ 3.24.2 5.4.0 7.4 - 3.1.1 + 3.1.2 2022.0.0 4.0.2 2.1.0 diff --git a/src/main/resources/generator/server/springboot/mvc/security/jwt/authentication/main/infrastructure/primary/SecurityConfiguration.java.mustache b/src/main/resources/generator/server/springboot/mvc/security/jwt/authentication/main/infrastructure/primary/SecurityConfiguration.java.mustache index f1522c88f0..f52b70838f 100644 --- a/src/main/resources/generator/server/springboot/mvc/security/jwt/authentication/main/infrastructure/primary/SecurityConfiguration.java.mustache +++ b/src/main/resources/generator/server/springboot/mvc/security/jwt/authentication/main/infrastructure/primary/SecurityConfiguration.java.mustache @@ -1,5 +1,7 @@ package {{packageName}}.authentication.infrastructure.primary; +import static org.springframework.security.web.util.matcher.AntPathRequestMatcher.*; + import {{packageName}}.authentication.domain.Role; import io.jsonwebtoken.Jwts; import io.jsonwebtoken.security.Keys; @@ -48,14 +50,14 @@ class SecurityConfiguration { return web -> web .ignoring() - .requestMatchers(HttpMethod.OPTIONS, "/**") - .requestMatchers("/app/**") - .requestMatchers("/i18n/**") - .requestMatchers("/content/**") - .requestMatchers("/swagger-ui/**") - .requestMatchers("/swagger-ui.html") - .requestMatchers("/v3/api-docs/**") - .requestMatchers("/test/**"); + .requestMatchers(antMatcher(HttpMethod.OPTIONS, "/**")) + .requestMatchers(antMatcher("/app/**")) + .requestMatchers(antMatcher("/i18n/**")) + .requestMatchers(antMatcher("/content/**")) + .requestMatchers(antMatcher("/swagger-ui/**")) + .requestMatchers(antMatcher("/swagger-ui.html")) + .requestMatchers(antMatcher("/v3/api-docs/**")) + .requestMatchers(antMatcher("/test/**")); } @Bean @@ -75,18 +77,18 @@ class SecurityConfiguration { .httpBasic(AbstractHttpConfigurer::disable) .sessionManagement(session -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS)) .authorizeHttpRequests(authz -> authz - .requestMatchers("/api/authenticate").permitAll() - .requestMatchers("/api/register").permitAll() - .requestMatchers("/api/activate").permitAll() - .requestMatchers("/api/account/reset-password/init").permitAll() - .requestMatchers("/api/account/reset-password/finish").permitAll() - .requestMatchers("/api/admin/**").hasAuthority(Role.ADMIN.key()) - .requestMatchers("/api/**").authenticated() - .requestMatchers("/management/health").permitAll() - .requestMatchers("/management/health/**").permitAll() - .requestMatchers("/management/info").permitAll() - .requestMatchers("/management/prometheus").permitAll() - .requestMatchers("/management/**").hasAuthority(Role.ADMIN.key()) + .requestMatchers(antMatcher("/api/authenticate")).permitAll() + .requestMatchers(antMatcher("/api/register")).permitAll() + .requestMatchers(antMatcher("/api/activate")).permitAll() + .requestMatchers(antMatcher("/api/account/reset-password/init")).permitAll() + .requestMatchers(antMatcher("/api/account/reset-password/finish")).permitAll() + .requestMatchers(antMatcher("/api/admin/**")).hasAuthority(Role.ADMIN.key()) + .requestMatchers(antMatcher("/api/**")).authenticated() + .requestMatchers(antMatcher("/management/health")).permitAll() + .requestMatchers(antMatcher("/management/health/**")).permitAll() + .requestMatchers(antMatcher("/management/info")).permitAll() + .requestMatchers(antMatcher("/management/prometheus")).permitAll() + .requestMatchers(antMatcher("/management/**")).hasAuthority(Role.ADMIN.key()) .anyRequest().authenticated() ); diff --git a/src/main/resources/generator/server/springboot/mvc/security/oauth2/core/main/infrastructure/primary/SecurityConfiguration.java.mustache b/src/main/resources/generator/server/springboot/mvc/security/oauth2/core/main/infrastructure/primary/SecurityConfiguration.java.mustache index bd48e71e34..d2f736558a 100644 --- a/src/main/resources/generator/server/springboot/mvc/security/oauth2/core/main/infrastructure/primary/SecurityConfiguration.java.mustache +++ b/src/main/resources/generator/server/springboot/mvc/security/oauth2/core/main/infrastructure/primary/SecurityConfiguration.java.mustache @@ -1,5 +1,7 @@ package {{packageName}}.authentication.infrastructure.primary; +import static org.springframework.security.web.util.matcher.AntPathRequestMatcher.*; + import java.time.Duration; import java.util.HashSet; import java.util.Set; @@ -64,14 +66,14 @@ public class SecurityConfiguration { return web -> web .ignoring() - .requestMatchers(HttpMethod.OPTIONS, "/**") - .requestMatchers("/app/**") - .requestMatchers("/i18n/**") - .requestMatchers("/content/**") - .requestMatchers("/swagger-ui/**") - .requestMatchers("/swagger-ui.html") - .requestMatchers("/v3/api-docs/**") - .requestMatchers("/test/**"); + .requestMatchers(antMatcher(HttpMethod.OPTIONS, "/**")) + .requestMatchers(antMatcher("/app/**")) + .requestMatchers(antMatcher("/i18n/**")) + .requestMatchers(antMatcher("/content/**")) + .requestMatchers(antMatcher("/swagger-ui/**")) + .requestMatchers(antMatcher("/swagger-ui.html")) + .requestMatchers(antMatcher("/v3/api-docs/**")) + .requestMatchers(antMatcher("/test/**")); } @Bean @@ -88,15 +90,15 @@ public class SecurityConfiguration { permissions.policy("camera=(), fullscreen=(self), geolocation=(), gyroscope=(), magnetometer=(), microphone=(), midi=(), payment=(), sync-xhr=()")) ) .authorizeHttpRequests(authz -> authz - .requestMatchers("/api/authenticate").permitAll() - .requestMatchers("/api/auth-info").permitAll() - .requestMatchers("/api/admin/**").hasAuthority(Role.ADMIN.key()) - .requestMatchers("/api/**").authenticated() - .requestMatchers("/management/health").permitAll() - .requestMatchers("/management/health/**").permitAll() - .requestMatchers("/management/info").permitAll() - .requestMatchers("/management/prometheus").permitAll() - .requestMatchers("/management/**").hasAuthority(Role.ADMIN.key()) + .requestMatchers(antMatcher("/api/authenticate")).permitAll() + .requestMatchers(antMatcher("/api/auth-info")).permitAll() + .requestMatchers(antMatcher("/api/admin/**")).hasAuthority(Role.ADMIN.key()) + .requestMatchers(antMatcher("/api/**")).authenticated() + .requestMatchers(antMatcher("/management/health")).permitAll() + .requestMatchers(antMatcher("/management/health/**")).permitAll() + .requestMatchers(antMatcher("/management/info")).permitAll() + .requestMatchers(antMatcher("/management/prometheus")).permitAll() + .requestMatchers(antMatcher("/management/**")).hasAuthority(Role.ADMIN.key()) .anyRequest().authenticated() ) .oauth2Login(withDefaults())