[JAVA-28945] Upgrade cloud-foundry-uaa to Spring Boot 3 (#16181)

This commit is contained in:
sam-gardner 2024-03-22 16:37:51 +00:00 committed by GitHub
parent da41c860a1
commit e65c1f851f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 9 deletions

View File

@ -1,6 +1,7 @@
package com.baeldung.cfuaa.oauth2.resourceserver; package com.baeldung.cfuaa.oauth2.resourceserver;
import org.springframework.context.annotation.Bean; 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.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.web.SecurityFilterChain; import org.springframework.security.web.SecurityFilterChain;
@ -10,16 +11,14 @@ public class CFUAAOAuth2ResourceServerSecurityConfiguration {
@Bean @Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http.authorizeRequests() http.authorizeHttpRequests(auth -> auth
.antMatchers("/read/**") .requestMatchers("/read/**")
.hasAuthority("SCOPE_resource.read") .hasAuthority("SCOPE_resource.read")
.antMatchers("/write/**") .requestMatchers("/write/**")
.hasAuthority("SCOPE_resource.write") .hasAuthority("SCOPE_resource.write")
.anyRequest() .anyRequest()
.authenticated() .authenticated())
.and() .oauth2ResourceServer((oauth2) -> oauth2.jwt(Customizer.withDefaults()));
.oauth2ResourceServer()
.jwt();
return http.build(); return http.build();
} }

View File

@ -9,9 +9,9 @@
<parent> <parent>
<groupId>com.baeldung</groupId> <groupId>com.baeldung</groupId>
<artifactId>parent-boot-2</artifactId> <artifactId>parent-boot-3</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
<relativePath>../../parent-boot-2</relativePath> <relativePath>../../parent-boot-3</relativePath>
</parent> </parent>
<modules> <modules>