package com.amazonaws.awssamples.microservices.security; import org.springframework.context.annotation.Bean; import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.web.SecurityFilterChain; /** * Spring boot security config. */ @EnableWebSecurity @EnableGlobalMethodSecurity(securedEnabled = true, prePostEnabled = true) // To configure method-level security public class SecurityConfig { @Bean public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { http.cors().and().csrf().disable() .authorizeRequests(expressionInterceptUrlRegistry -> expressionInterceptUrlRegistry .anyRequest().authenticated()) .oauth2ResourceServer().jwt(); return http.build(); } }