From e65c1f851fa27ea9d2b61c8f2a5160139e5e6865 Mon Sep 17 00:00:00 2001 From: sam-gardner <53271849+sam-gardner@users.noreply.github.com> Date: Fri, 22 Mar 2024 16:37:51 +0000 Subject: [PATCH] [JAVA-28945] Upgrade cloud-foundry-uaa to Spring Boot 3 (#16181) --- ...AAOAuth2ResourceServerSecurityConfiguration.java | 13 ++++++------- security-modules/cloud-foundry-uaa/pom.xml | 4 ++-- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/security-modules/cloud-foundry-uaa/cf-uaa-oauth2-resource-server/src/main/java/com/baeldung/cfuaa/oauth2/resourceserver/CFUAAOAuth2ResourceServerSecurityConfiguration.java b/security-modules/cloud-foundry-uaa/cf-uaa-oauth2-resource-server/src/main/java/com/baeldung/cfuaa/oauth2/resourceserver/CFUAAOAuth2ResourceServerSecurityConfiguration.java index 9bdee7f732..0ce558f9e0 100644 --- a/security-modules/cloud-foundry-uaa/cf-uaa-oauth2-resource-server/src/main/java/com/baeldung/cfuaa/oauth2/resourceserver/CFUAAOAuth2ResourceServerSecurityConfiguration.java +++ b/security-modules/cloud-foundry-uaa/cf-uaa-oauth2-resource-server/src/main/java/com/baeldung/cfuaa/oauth2/resourceserver/CFUAAOAuth2ResourceServerSecurityConfiguration.java @@ -1,6 +1,7 @@ package com.baeldung.cfuaa.oauth2.resourceserver; import org.springframework.context.annotation.Bean; +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.web.SecurityFilterChain; @@ -10,16 +11,14 @@ public class CFUAAOAuth2ResourceServerSecurityConfiguration { @Bean public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { - http.authorizeRequests() - .antMatchers("/read/**") + http.authorizeHttpRequests(auth -> auth + .requestMatchers("/read/**") .hasAuthority("SCOPE_resource.read") - .antMatchers("/write/**") + .requestMatchers("/write/**") .hasAuthority("SCOPE_resource.write") .anyRequest() - .authenticated() - .and() - .oauth2ResourceServer() - .jwt(); + .authenticated()) + .oauth2ResourceServer((oauth2) -> oauth2.jwt(Customizer.withDefaults())); return http.build(); } diff --git a/security-modules/cloud-foundry-uaa/pom.xml b/security-modules/cloud-foundry-uaa/pom.xml index ff26d56dc3..4ba70fbd43 100644 --- a/security-modules/cloud-foundry-uaa/pom.xml +++ b/security-modules/cloud-foundry-uaa/pom.xml @@ -9,9 +9,9 @@ com.baeldung - parent-boot-2 + parent-boot-3 0.0.1-SNAPSHOT - ../../parent-boot-2 + ../../parent-boot-3