JAVA-14899 Update cloud-foundry-uaa module under security-modules to remove usage of deprecated WebSecurityConfigurerAdapter (#13032)
This commit is contained in:
parent
8339687190
commit
de51a5155a
|
@ -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 {
|
||||||
|
|
||||||
|
@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();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void configure(HttpSecurity http) throws Exception {
|
|
||||||
http
|
|
||||||
.authorizeRequests()
|
|
||||||
.antMatchers("/read/**").hasAuthority("SCOPE_resource.read")
|
|
||||||
.antMatchers("/write/**").hasAuthority("SCOPE_resource.write")
|
|
||||||
.anyRequest().authenticated()
|
|
||||||
.and()
|
|
||||||
.oauth2ResourceServer()
|
|
||||||
.jwt();
|
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue