Skip to content

Commit de51a51

Browse files
JAVA-14899 Update cloud-foundry-uaa module under security-modules to remove usage of deprecated WebSecurityConfigurerAdapter (#13032)
1 parent 8339687 commit de51a51

1 file changed

Lines changed: 18 additions & 13 deletions

File tree

Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
11
package com.baeldung.cfuaa.oauth2.resourceserver;
22

3+
import org.springframework.context.annotation.Bean;
34
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
45
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
5-
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
6+
import org.springframework.security.web.SecurityFilterChain;
67

78
@EnableWebSecurity
8-
public class CFUAAOAuth2ResourceServerSecurityConfiguration extends WebSecurityConfigurerAdapter {
9+
public class CFUAAOAuth2ResourceServerSecurityConfiguration {
10+
11+
@Bean
12+
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
13+
http.authorizeRequests()
14+
.antMatchers("/read/**")
15+
.hasAuthority("SCOPE_resource.read")
16+
.antMatchers("/write/**")
17+
.hasAuthority("SCOPE_resource.write")
18+
.anyRequest()
19+
.authenticated()
20+
.and()
21+
.oauth2ResourceServer()
22+
.jwt();
23+
return http.build();
24+
}
925

10-
@Override
11-
protected void configure(HttpSecurity http) throws Exception {
12-
http
13-
.authorizeRequests()
14-
.antMatchers("/read/**").hasAuthority("SCOPE_resource.read")
15-
.antMatchers("/write/**").hasAuthority("SCOPE_resource.write")
16-
.anyRequest().authenticated()
17-
.and()
18-
.oauth2ResourceServer()
19-
.jwt();
20-
}
2126
}

0 commit comments

Comments
 (0)