content: package com.example.apigatewayservice.security;
  
  import lombok.extern.slf4j.Slf4j;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.context.annotation.Bean;
  import org.springframework.context.annotation.Configuration;
  import org.springframework.core.annotation.Order;
  import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity;
  import org.springframework.security.config.web.server.SecurityWebFiltersOrder;
  import org.springframework.security.config.web.server.ServerHttpSecurity;
  import org.springframework.security.web.server.SecurityWebFilterChain;
  
  @Configuration
  @EnableWebFluxSecurity
  @Order(0)
  @Slf4j
  public class SecurityConfig {
  
  
      @Autowired
      private CustomAuthenticationFilter customAuthenticationFilter;
  
      @Bean
      public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
          http
                  .csrf(ServerHttpSecurity.CsrfSpec::disable)
                  .authorizeExchange(exchanges -> exchanges
                          .pathMatchers("/identity-service/api/auth/register",
                                  "/identity-service/api/auth/authenticate","/demo-controller/api/test/demo-controller/greet","/identity-service/api/auth/logout")
                          .permitAll()
                  )
                  .addFilterAt(customAuthenticationFilter, SecurityWebFiltersOrder.AUTHENTICATION);
  
          return http.build();
      }
  }
  