Skip to content

Commit 9540cfc

Browse files
authored
Merge pull request #332 from anuragkumawat/JAVA-15692
JAVA-15692 Update oauth-rest module under spring-security-oauth repo to remove usage of deprecated WebSecurityConfigurerAdapter
2 parents 847f69f + 24ec783 commit 9540cfc

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed
Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,28 @@
11
package com.baeldung.resource.spring;
22

3+
import org.springframework.context.annotation.Bean;
34
import org.springframework.context.annotation.Configuration;
45
import org.springframework.http.HttpMethod;
56
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
6-
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
7+
import org.springframework.security.web.SecurityFilterChain;
78

89
@Configuration
9-
public class SecurityConfig extends WebSecurityConfigurerAdapter {
10+
public class SecurityConfig {
1011

11-
@Override
12-
protected void configure(HttpSecurity http) throws Exception {// @formatter:off
12+
@Bean
13+
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
1314
http.cors()
1415
.and()
15-
.authorizeRequests()
16-
.antMatchers(HttpMethod.GET, "/user/info", "/api/foos/**")
17-
.hasAuthority("SCOPE_read")
18-
.antMatchers(HttpMethod.POST, "/api/foos")
19-
.hasAuthority("SCOPE_write")
20-
.anyRequest()
21-
.authenticated()
16+
.authorizeRequests()
17+
.antMatchers(HttpMethod.GET, "/user/info", "/api/foos/**")
18+
.hasAuthority("SCOPE_read")
19+
.antMatchers(HttpMethod.POST, "/api/foos")
20+
.hasAuthority("SCOPE_write")
21+
.anyRequest()
22+
.authenticated()
2223
.and()
23-
.oauth2ResourceServer()
24-
.jwt();
25-
}//@formatter:on
26-
24+
.oauth2ResourceServer()
25+
.jwt();
26+
return http.build();
27+
}
2728
}

oauth-rest/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<parent>
1212
<groupId>org.springframework.boot</groupId>
1313
<artifactId>spring-boot-starter-parent</artifactId>
14-
<version>2.6.7</version>
14+
<version>2.7.5</version>
1515
<relativePath /> <!-- lookup parent from repository -->
1616
</parent>
1717

0 commit comments

Comments
 (0)