Skip to content

Commit

Permalink
Fikset SecurityConfig for UDIStub
Browse files Browse the repository at this point in the history
  • Loading branch information
stigus committed Oct 27, 2023
1 parent b47cc18 commit 1c86dd3
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,23 @@
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.servlet.util.matcher.MvcRequestMatcher;
import org.springframework.web.servlet.handler.HandlerMappingIntrospector;

@EnableWebSecurity
@Configuration
@Profile({ "prod", "dev" })
public class SecurityConfig {

@Bean
public SecurityFilterChain filterChain(HttpSecurity httpSecurity) throws Exception {
public SecurityFilterChain filterChain(HttpSecurity httpSecurity, HandlerMappingIntrospector introspector) throws Exception {

MvcRequestMatcher.Builder mvcMatcherBuilder = new MvcRequestMatcher.Builder(introspector);

httpSecurity.sessionManagement(sessionConfig -> sessionConfig.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
.csrf(AbstractHttpConfigurer::disable)
.authorizeHttpRequests(authorizeConfig -> authorizeConfig
.requestMatchers("/api/**").fullyAuthenticated()
.requestMatchers(mvcMatcherBuilder.pattern("/api/**")).fullyAuthenticated()
.anyRequest().permitAll())
.oauth2ResourceServer(oauth2RSConfig -> oauth2RSConfig.jwt(Customizer.withDefaults()));

Expand Down

0 comments on commit 1c86dd3

Please sign in to comment.