JAVA-14899 Update cloud-foundry-uaa module under security-modules to remove usage of deprecated WebSecurityConfigurerAdapter (#13032)

This commit is contained in:
anuragkumawat 2022-11-18 00:04:39 +05:30 committed by GitHub
parent 8339687190
commit de51a5155a

View File

@ -1,21 +1,26 @@
package com.baeldung.cfuaa.oauth2.resourceserver; 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.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; 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 @EnableWebSecurity
public class CFUAAOAuth2ResourceServerSecurityConfiguration extends WebSecurityConfigurerAdapter { public class CFUAAOAuth2ResourceServerSecurityConfiguration {
@Override @Bean
protected void configure(HttpSecurity http) throws Exception { public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http http.authorizeRequests()
.authorizeRequests() .antMatchers("/read/**")
.antMatchers("/read/**").hasAuthority("SCOPE_resource.read") .hasAuthority("SCOPE_resource.read")
.antMatchers("/write/**").hasAuthority("SCOPE_resource.write") .antMatchers("/write/**")
.anyRequest().authenticated() .hasAuthority("SCOPE_resource.write")
.anyRequest()
.authenticated()
.and() .and()
.oauth2ResourceServer() .oauth2ResourceServer()
.jwt(); .jwt();
return http.build();
} }
} }