package com.mosquito.project.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.web.SecurityFilterChain;

/**
 * E2E测试专用Spring Security配置
 * 在e2e profile下禁用所有安全检查，允许API请求直接访问
 */
@Configuration
@EnableWebSecurity
@Profile("e2e")
public class E2eSecurityConfig {

    @Bean
    public SecurityFilterChain e2eSecurityFilterChain(HttpSecurity http) throws Exception {
        http
            .csrf(csrf -> csrf.disable())
            .authorizeHttpRequests(auth -> auth
                .anyRequest().permitAll()
            );
        return http.build();
    }
}