22
33import static org .myteam .server .global .security .jwt .JwtProvider .*;
44
5+ import org .myteam .server .global .config .WebConfig ;
56import org .myteam .server .global .security .filter .AuthenticationEntryPointHandler ;
67import org .myteam .server .global .security .filter .CustomAccessDeniedHandler ;
78import org .myteam .server .global .security .filter .JwtAuthenticationFilter ;
@@ -183,8 +184,6 @@ public class SecurityConfig {
183184 /** @brief Check Access Member */ "/test/cert" ,
184185 };
185186
186- @ Value ("${FRONT_URL:http://localhost:3000}" )
187- private String frontUrl ;
188187 private final JwtProvider jwtProvider ;
189188 private final CustomUserDetailsService customUserDetailsService ;
190189 private final CustomOAuth2UserService customOAuth2UserService ;
@@ -193,12 +192,7 @@ public class SecurityConfig {
193192 private final ApplicationEventPublisher eventPublisher ;
194193 private final RedisService redisService ;
195194 private final MemberJpaRepository memberJpaRepository ;
196-
197- @ PostConstruct
198- public void init () {
199- log .debug ("init security config" );
200- log .debug ("frontUrl = {}" , frontUrl );
201- }
195+ private final WebConfig webConfig ;
202196
203197 @ Bean
204198 public BCryptPasswordEncoder passwordEncoder () {
@@ -245,7 +239,7 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti
245239 // .addFilter(webConfig.corsFilter()); // CORS 필터 추가
246240
247241 // // cors 설정
248- http .cors ((corsCustomizer ) -> corsCustomizer .configurationSource (configurationSource ()));
242+ http .cors ((corsCustomizer ) -> corsCustomizer .configurationSource (webConfig . configurationSource ()));
249243
250244 // 예외 처리 핸들러 설정
251245 http .exceptionHandling (exceptionHandling -> exceptionHandling
@@ -287,20 +281,4 @@ public AuthenticationManager authenticationManager() {
287281 return new ProviderManager (provider );
288282 }
289283
290- public CorsConfigurationSource configurationSource () {
291- CorsConfiguration configuration = new CorsConfiguration ();
292- configuration .addAllowedHeader ("*" );
293- configuration .addAllowedMethod ("*" );
294- configuration .addAllowedOriginPattern (frontUrl ); // TODO_ 추후 변경 해야함 배포시
295- configuration .addAllowedOriginPattern ("http://localhost:3000" ); // TODO_ 추후 변경 해야함 배포시
296- configuration .addAllowedOriginPattern ("https://main.dbbilwoxps3tu.amplifyapp.com" );
297- configuration .addAllowedOriginPattern ("https://playhive.co.kr" );
298- configuration .setAllowCredentials (true );
299- configuration .addExposedHeader (HEADER_AUTHORIZATION );
300- configuration .addExposedHeader (REFRESH_TOKEN_KEY );
301- UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource ();
302- source .registerCorsConfiguration ("/**" , configuration );
303- return source ;
304- }
305-
306284}
0 commit comments