Skip to content

Commit 364dd21

Browse files
authored
Merge pull request #44 from code-review-platform-flow/FLOW-84
feat: order 수정
2 parents 6b7d3b0 + 45a1ea8 commit 364dd21

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/main/java/org/flow/gateway/common/security/SecurityConfig.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
package org.flow.gateway.common.security;
22

3+
import java.util.Arrays;
4+
35
import org.springframework.context.annotation.Bean;
46
import org.springframework.context.annotation.Configuration;
57
import org.springframework.security.config.Customizer;
68
import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity;
79
import org.springframework.security.config.web.server.ServerHttpSecurity;
810
import org.springframework.security.web.server.SecurityWebFilterChain;
11+
import org.springframework.web.cors.CorsConfiguration;
12+
import org.springframework.web.cors.reactive.CorsConfigurationSource;
13+
import org.springframework.web.cors.reactive.UrlBasedCorsConfigurationSource;
914

1015
@Configuration
1116
@EnableWebFluxSecurity
@@ -14,7 +19,8 @@ public class SecurityConfig {
1419
@Bean
1520
public SecurityWebFilterChain securityWebFilterChain(ServerHttpSecurity http) {
1621
http
17-
.csrf(ServerHttpSecurity.CsrfSpec::disable)
22+
.csrf(ServerHttpSecurity.CsrfSpec::disable) // CSRF 비활성화
23+
.cors(corsSpec -> corsSpec.configurationSource(corsConfigurationSource())) // CORS 설정 추가
1824
.authorizeExchange(exchanges -> exchanges
1925
.anyExchange().permitAll()
2026
)
@@ -24,4 +30,17 @@ public SecurityWebFilterChain securityWebFilterChain(ServerHttpSecurity http) {
2430
return http.build();
2531
}
2632

33+
@Bean
34+
public CorsConfigurationSource corsConfigurationSource() {
35+
CorsConfiguration corsConfig = new CorsConfiguration();
36+
corsConfig.setAllowedOrigins(Arrays.asList("http://localhost:3000", "http://your-other-allowed-origin.com"));
37+
corsConfig.setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "DELETE"));
38+
corsConfig.setAllowedHeaders(Arrays.asList("*"));
39+
corsConfig.setAllowCredentials(true);
40+
41+
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
42+
source.registerCorsConfiguration("/**", corsConfig);
43+
return source;
44+
}
2745
}
46+

0 commit comments

Comments
 (0)