File tree Expand file tree Collapse file tree
src/main/java/UMC_7th/Closit Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package UMC_7th .Closit .global .config ;
2+
3+ import org .springframework .context .annotation .Bean ;
4+ import org .springframework .context .annotation .Configuration ;
5+ import org .springframework .http .HttpMethod ;
6+ import org .springframework .web .cors .CorsConfiguration ;
7+ import org .springframework .web .cors .CorsConfigurationSource ;
8+ import org .springframework .web .cors .UrlBasedCorsConfigurationSource ;
9+
10+ import java .util .List ;
11+
12+ @ Configuration
13+ public class CorsConfig {
14+
15+ @ Bean
16+ public CorsConfigurationSource corsConfigurationSource () {
17+ CorsConfiguration config = new CorsConfiguration ();
18+
19+ config .addAllowedOriginPattern ("*" );
20+ config .setAllowedMethods (List .of (
21+ HttpMethod .POST .name (),
22+ HttpMethod .GET .name (),
23+ HttpMethod .PUT .name (),
24+ HttpMethod .DELETE .name (),
25+ HttpMethod .PATCH .name (),
26+ HttpMethod .OPTIONS .name ()
27+ ));
28+ config .setAllowedHeaders (List .of ("*" ));
29+ config .setAllowCredentials (true );
30+
31+ UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource ();
32+ source .registerCorsConfiguration ("/**" , config );
33+
34+ return source ;
35+ }
36+ }
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 66import org .springframework .context .annotation .Bean ;
77import org .springframework .context .annotation .Configuration ;
88import org .springframework .security .authentication .AuthenticationManager ;
9+ import org .springframework .security .config .Customizer ;
910import org .springframework .security .config .annotation .authentication .configuration .AuthenticationConfiguration ;
1011import org .springframework .security .config .annotation .web .builders .HttpSecurity ;
11- import org .springframework .security .config .annotation .web .configuration .WebSecurityCustomizer ;
1212import org .springframework .security .config .annotation .web .configurers .AbstractHttpConfigurer ;
1313import org .springframework .security .config .http .SessionCreationPolicy ;
1414import org .springframework .security .crypto .bcrypt .BCryptPasswordEncoder ;
@@ -28,6 +28,7 @@ public class SecurityConfig {
2828 @ Bean
2929 public SecurityFilterChain securityFilterChain (HttpSecurity http ) throws Exception {
3030 http
31+ .cors (Customizer .withDefaults ())
3132 .csrf (AbstractHttpConfigurer ::disable )
3233 .exceptionHandling ((exceptionHandling ) -> exceptionHandling
3334 .accessDeniedHandler (jwtAccessDeniedHandler ) // 인증은 되었지만 권한이 부족할 때
@@ -63,7 +64,6 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti
6364
6465 }
6566
66-
6767 @ Bean
6868 public PasswordEncoder passwordEncoder () {
6969 return new BCryptPasswordEncoder ();
You can’t perform that action at this time.
0 commit comments