Skip to content

Commit

Permalink
hotfix: Cors 재설정
Browse files Browse the repository at this point in the history
  • Loading branch information
khcho0125 committed Dec 8, 2022
1 parent 6b4760e commit 251f2b6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ import org.springframework.security.config.http.SessionCreationPolicy
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder
import org.springframework.security.crypto.password.PasswordEncoder
import org.springframework.security.web.SecurityFilterChain
import org.springframework.web.cors.CorsConfiguration
import org.springframework.web.cors.CorsConfigurationSource
import org.springframework.web.cors.UrlBasedCorsConfigurationSource
import team.comit.simtong.domain.user.model.Authority.ROLE_ADMIN
import team.comit.simtong.domain.user.model.Authority.ROLE_COMMON
import team.comit.simtong.domain.user.model.Authority.ROLE_SUPER
Expand All @@ -36,7 +33,7 @@ class SecurityConfig(
@Bean
protected fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
http
.cors().configurationSource(corsConfiguration()).and()
.cors().and()
.csrf().disable()
.formLogin().disable()

Expand Down Expand Up @@ -107,18 +104,4 @@ class SecurityConfig(
@Bean
protected fun PasswordEncoder(): PasswordEncoder = BCryptPasswordEncoder()

@Bean
protected fun corsConfiguration() : CorsConfigurationSource {
return UrlBasedCorsConfigurationSource().apply {
registerCorsConfiguration(
"/**",
CorsConfiguration().apply {
allowCredentials = true
allowedOriginPatterns = listOf("*")
allowedHeaders = listOf("*")
allowedMethods = listOf("*")
}
)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package team.comit.simtong.global.config

import org.springframework.context.annotation.Configuration
import org.springframework.web.servlet.config.annotation.CorsRegistry
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer

/**
*
* Cors 관련 설정을 하는 WebMvcConfig
*
* @author Chokyunghyeon
* @date 2022/12/08
* @version 1.0.0
**/
@Configuration
class WebMvcConfig : WebMvcConfigurer {

override fun addCorsMappings(registry: CorsRegistry) {
registry.addMapping("/**")
.allowedMethods("*")
.allowedOriginPatterns("*")
}
}

0 comments on commit 251f2b6

Please sign in to comment.