Update cloud-foundry-uaa module under security-modules to remove usage of deprecated WebSecurityConfigurerAdapter
package com.baeldung.cfuaa.oauth2.resourceserver;
+import org.springframework.context.annotation.Bean;
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.web.SecurityFilterChain;
@EnableWebSecurity
-public class CFUAAOAuth2ResourceServerSecurityConfiguration extends WebSecurityConfigurerAdapter {
+public class CFUAAOAuth2ResourceServerSecurityConfiguration {
- @Override
- protected void configure(HttpSecurity http) throws Exception {
- http
- .authorizeRequests()
- .antMatchers("/read/**").hasAuthority("SCOPE_resource.read")
- .antMatchers("/write/**").hasAuthority("SCOPE_resource.write")
- .anyRequest().authenticated()
+ @Bean
+ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
+ http.authorizeRequests()
+ .antMatchers("/read/**")
+ .hasAuthority("SCOPE_resource.read")
+ .antMatchers("/write/**")
+ .hasAuthority("SCOPE_resource.write")
+ .anyRequest()
+ .authenticated()
.and()
.oauth2ResourceServer()
.jwt();
+ return http.build();
}
+
}
\ No newline at end of file
