From 71e8c19db74cc8d580476831671e5ab781cbbc9a Mon Sep 17 00:00:00 2001 From: gilgeunwoo Date: Mon, 18 Dec 2023 19:32:41 +0900 Subject: [PATCH] fix :: cors --- .../global/security/SecurityConfig.kt | 1 + .../global/web/WebSecurityConfig.kt | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 JuGanBbojjak-infrastructure/src/main/kotlin/com/kodomo/juganbbojjak/global/web/WebSecurityConfig.kt diff --git a/JuGanBbojjak-infrastructure/src/main/kotlin/com/kodomo/juganbbojjak/global/security/SecurityConfig.kt b/JuGanBbojjak-infrastructure/src/main/kotlin/com/kodomo/juganbbojjak/global/security/SecurityConfig.kt index c41c3a2..9cde982 100644 --- a/JuGanBbojjak-infrastructure/src/main/kotlin/com/kodomo/juganbbojjak/global/security/SecurityConfig.kt +++ b/JuGanBbojjak-infrastructure/src/main/kotlin/com/kodomo/juganbbojjak/global/security/SecurityConfig.kt @@ -33,6 +33,7 @@ class SecurityConfig( it .requestMatchers(HttpMethod.POST, "/event_schedules/{weekly-event-schedule-id}").hasAuthority(USER.name) .requestMatchers(HttpMethod.GET, "/event_schedules/{weekly-event-schedule-id}").hasAnyAuthority(ADMIN.name, USER.name) + .requestMatchers(HttpMethod.PUT, "/event_schedules/{event-schedule-id}").hasAnyAuthority(ADMIN.name, USER.name) .requestMatchers(HttpMethod.POST, "/work_report/{weekly-work-report-id}").hasAuthority(USER.name) .requestMatchers(HttpMethod.GET, "/work_report/{weekly-work-report-id}").hasAnyAuthority(USER.name, ADMIN.name) diff --git a/JuGanBbojjak-infrastructure/src/main/kotlin/com/kodomo/juganbbojjak/global/web/WebSecurityConfig.kt b/JuGanBbojjak-infrastructure/src/main/kotlin/com/kodomo/juganbbojjak/global/web/WebSecurityConfig.kt new file mode 100644 index 0000000..1d07d60 --- /dev/null +++ b/JuGanBbojjak-infrastructure/src/main/kotlin/com/kodomo/juganbbojjak/global/web/WebSecurityConfig.kt @@ -0,0 +1,17 @@ +package com.kodomo.juganbbojjak.global.web + +import org.springframework.context.annotation.Configuration +import org.springframework.web.servlet.config.annotation.CorsRegistry +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer + +@Configuration +class WebSecurityConfig : WebMvcConfigurer { + + override fun addCorsMappings(registry: CorsRegistry) { + registry + .addMapping("/**") + .allowedOrigins("*") + .allowedMethods("GET", "POST", "PUT", "PATCH", "DELETE", "HEAD") + .allowedHeaders("*") + } +}