File tree Expand file tree Collapse file tree
security-modules/cloud-foundry-uaa/cf-uaa-oauth2-resource-server/src/main/java/com/baeldung/cfuaa/oauth2/resourceserver Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11package com .baeldung .cfuaa .oauth2 .resourceserver ;
22
3+ import org .springframework .context .annotation .Bean ;
34import org .springframework .security .config .annotation .web .builders .HttpSecurity ;
45import 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}
You can’t perform that action at this time.
0 commit comments