11package io .github .patternatlas .api .config ;
22
3+ import org .springframework .boot .autoconfigure .security .oauth2 .resource .JwtAccessTokenConverterConfigurer ;
34import org .springframework .boot .web .servlet .FilterRegistrationBean ;
45import org .springframework .context .annotation .Bean ;
56import org .springframework .context .annotation .Configuration ;
67import org .springframework .core .Ordered ;
8+ import org .springframework .security .config .annotation .method .configuration .EnableGlobalMethodSecurity ;
79import org .springframework .security .config .annotation .web .builders .HttpSecurity ;
810import org .springframework .security .config .http .SessionCreationPolicy ;
911import org .springframework .security .crypto .bcrypt .BCryptPasswordEncoder ;
1012import org .springframework .security .crypto .password .PasswordEncoder ;
1113import org .springframework .security .oauth2 .config .annotation .web .configuration .EnableResourceServer ;
1214import org .springframework .security .oauth2 .config .annotation .web .configuration .ResourceServerConfigurerAdapter ;
1315import org .springframework .security .oauth2 .config .annotation .web .configurers .ResourceServerSecurityConfigurer ;
16+ import org .springframework .security .oauth2 .provider .OAuth2Authentication ;
17+ import org .springframework .security .oauth2 .provider .token .DefaultAccessTokenConverter ;
18+ import org .springframework .security .oauth2 .provider .token .DefaultTokenServices ;
19+ import org .springframework .security .oauth2 .provider .token .store .JwtAccessTokenConverter ;
20+ import org .springframework .security .oauth2 .provider .token .store .JwtTokenStore ;
1421import org .springframework .web .cors .CorsConfiguration ;
1522import org .springframework .web .cors .UrlBasedCorsConfigurationSource ;
1623import org .springframework .web .filter .CorsFilter ;
1724
25+ import java .util .Map ;
26+
1827@ Configuration
1928@ EnableResourceServer
20- // START::Comment for local development with authorization
21- //@EnableGlobalMethodSecurity(prePostEnabled = true)
22- // END::Comment for local development with authorization
2329class ResourceServerConfig extends ResourceServerConfigurerAdapter {
2430
2531 @ Override
@@ -29,17 +35,7 @@ public void configure(HttpSecurity http) throws Exception {
2935 .antMatchers ("/**" )
3036 .and ()
3137 .authorizeRequests ()
32- .antMatchers ("/swagger-ui/**" ).permitAll ()
33- // START::Comment for local development with authorization
34- // .antMatchers(HttpMethod.GET, "/**").permitAll()
35- // .antMatchers(HttpMethod.POST, "/**").access("#oauth2.hasScope('write')")
36- // .antMatchers(HttpMethod.PUT, "/**").access("#oauth2.hasScope('write')")
37- // .antMatchers(HttpMethod.DELETE, "/**").hasAuthority("ADMIN")
38- // .anyRequest().authenticated()
39- //END::Comment for local development with authorization
40- // START::Uncomment for local development without authorization
4138 .anyRequest ().permitAll ()
42- // END::Uncomment for local development without authorization
4339 .and ()
4440 .sessionManagement ()
4541 .sessionCreationPolicy (SessionCreationPolicy .STATELESS );
@@ -69,4 +65,5 @@ public FilterRegistrationBean customCorsFilter() {
6965 bean .setOrder (Ordered .HIGHEST_PRECEDENCE );
7066 return bean ;
7167 }
68+
7269}
0 commit comments