Fix CORS settings
This commit is contained in:
parent
882108c006
commit
3ed5d700bd
1 changed files with 5 additions and 1 deletions
|
@ -6,6 +6,7 @@ import org.springframework.context.annotation.Bean
|
||||||
import org.springframework.context.annotation.Configuration
|
import org.springframework.context.annotation.Configuration
|
||||||
import org.springframework.core.env.Environment
|
import org.springframework.core.env.Environment
|
||||||
import org.springframework.core.env.get
|
import org.springframework.core.env.get
|
||||||
|
import org.springframework.http.HttpMethod
|
||||||
import org.springframework.security.authentication.dao.DaoAuthenticationProvider
|
import org.springframework.security.authentication.dao.DaoAuthenticationProvider
|
||||||
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder
|
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder
|
||||||
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity
|
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity
|
||||||
|
@ -68,7 +69,10 @@ open class SecurityConfig(
|
||||||
.configurationSource {
|
.configurationSource {
|
||||||
with(CorsConfiguration()) {
|
with(CorsConfiguration()) {
|
||||||
applyPermitDefaultValues()
|
applyPermitDefaultValues()
|
||||||
allowedOrigins = environment.get("twigs.cors.domains")?.split(",")
|
allowedOrigins = environment["twigs.cors.domains"]?.split(",") ?: listOf("*")
|
||||||
|
allowedMethods = listOf(HttpMethod.GET, HttpMethod.POST, HttpMethod.PUT, HttpMethod.DELETE)
|
||||||
|
.map { it.name }
|
||||||
|
allowCredentials = true
|
||||||
this
|
this
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue