diff --git a/src/main/java/com/helpmeCookies/global/security/WebSecurityConfig.java b/src/main/java/com/helpmeCookies/global/security/WebSecurityConfig.java index fbfc56a..eeda844 100644 --- a/src/main/java/com/helpmeCookies/global/security/WebSecurityConfig.java +++ b/src/main/java/com/helpmeCookies/global/security/WebSecurityConfig.java @@ -1,5 +1,7 @@ package com.helpmeCookies.global.security; +import static org.springframework.security.config.Customizer.*; + import java.util.Arrays; import org.springframework.context.annotation.Bean; @@ -40,7 +42,6 @@ public WebSecurityCustomizer configure() { @Bean public SecurityFilterChain oauth2SecurityFilterChain(HttpSecurity http) throws Exception { - http.cors((cors) -> cors.configurationSource(corsConfigurationSource())); http .securityMatcher("/oauth2/**") .csrf(AbstractHttpConfigurer::disable) @@ -72,8 +73,7 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { http.csrf(AbstractHttpConfigurer::disable); http.sessionManagement((session) -> session .sessionCreationPolicy(SessionCreationPolicy.STATELESS)); - http.cors((cors) -> cors.configurationSource(corsConfigurationSource())); - + http.cors(withDefaults()); http.authorizeHttpRequests((authorize) -> authorize .requestMatchers(HttpMethod.OPTIONS, "/**").permitAll() @@ -99,22 +99,8 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { return http.build(); } - @Bean - public CorsConfigurationSource corsConfigurationSource() { - CorsConfiguration configuration = new CorsConfiguration(); - configuration.setAllowedOrigins(Arrays.asList("http://1.618.s3-website.ap-northeast-2.amazonaws.com","http://localhost:3000")); - configuration.setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "DELETE", "OPTIONS")); - configuration.setAllowedHeaders(Arrays.asList("Authorization", "Content-Type", "X-Requested-With", "accept", "Origin", "Access-Control-Request-Method", "Access-Control-Request-Headers")); - configuration.setAllowCredentials(true); - - UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); - source.registerCorsConfiguration("/**", configuration); - return source; - } - @Bean public BCryptPasswordEncoder bCryptPasswordEncoder() { return new BCryptPasswordEncoder(); } - } \ No newline at end of file