File tree Expand file tree Collapse file tree 2 files changed +17
-16
lines changed
oauth-resource-server/src/main/java/com/baeldung/resource/spring Expand file tree Collapse file tree 2 files changed +17
-16
lines changed Original file line number Diff line number Diff line change 1
1
package com .baeldung .resource .spring ;
2
2
3
+ import org .springframework .context .annotation .Bean ;
3
4
import org .springframework .context .annotation .Configuration ;
4
5
import org .springframework .http .HttpMethod ;
5
6
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 ;
7
8
8
9
@ Configuration
9
- public class SecurityConfig extends WebSecurityConfigurerAdapter {
10
+ public class SecurityConfig {
10
11
11
- @ Override
12
- protected void configure (HttpSecurity http ) throws Exception {// @formatter:off
12
+ @ Bean
13
+ public SecurityFilterChain filterChain (HttpSecurity http ) throws Exception {
13
14
http .cors ()
14
15
.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 ()
22
23
.and ()
23
- .oauth2ResourceServer ()
24
- .jwt ();
25
- } //@formatter:on
26
-
24
+ .oauth2ResourceServer ()
25
+ .jwt ();
26
+ return http . build ();
27
+ }
27
28
}
Original file line number Diff line number Diff line change 11
11
<parent >
12
12
<groupId >org.springframework.boot</groupId >
13
13
<artifactId >spring-boot-starter-parent</artifactId >
14
- <version >2.6.7 </version >
14
+ <version >2.7.5 </version >
15
15
<relativePath /> <!-- lookup parent from repository -->
16
16
</parent >
17
17
You can’t perform that action at this time.
0 commit comments