mirror of
https://github.com/gotson/komga.git
synced 2026-05-09 05:10:19 +02:00
fix: allow cors configuration
allowed origins can be set via komga.cors.allowed-origins closes #540
This commit is contained in:
parent
0e42806ab4
commit
f435b9dc78
3 changed files with 9 additions and 3 deletions
|
|
@ -22,6 +22,8 @@ class KomgaProperties {
|
||||||
|
|
||||||
var database = Database()
|
var database = Database()
|
||||||
|
|
||||||
|
var cors = Cors()
|
||||||
|
|
||||||
class RememberMe {
|
class RememberMe {
|
||||||
@get:NotBlank
|
@get:NotBlank
|
||||||
var key: String? = null
|
var key: String? = null
|
||||||
|
|
@ -30,6 +32,10 @@ class KomgaProperties {
|
||||||
var validity: Int = 1209600 // 2 weeks
|
var validity: Int = 1209600 // 2 weeks
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class Cors {
|
||||||
|
var allowedOrigins: List<String> = emptyList()
|
||||||
|
}
|
||||||
|
|
||||||
class Database {
|
class Database {
|
||||||
@get:NotBlank
|
@get:NotBlank
|
||||||
var file: String = ""
|
var file: String = ""
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ import org.gotson.komga.domain.model.ROLE_USER
|
||||||
import org.gotson.komga.infrastructure.configuration.KomgaProperties
|
import org.gotson.komga.infrastructure.configuration.KomgaProperties
|
||||||
import org.springframework.boot.actuate.autoconfigure.security.servlet.EndpointRequest
|
import org.springframework.boot.actuate.autoconfigure.security.servlet.EndpointRequest
|
||||||
import org.springframework.context.annotation.Bean
|
import org.springframework.context.annotation.Bean
|
||||||
import org.springframework.context.annotation.Profile
|
|
||||||
import org.springframework.http.HttpHeaders
|
import org.springframework.http.HttpHeaders
|
||||||
import org.springframework.http.HttpMethod
|
import org.springframework.http.HttpMethod
|
||||||
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity
|
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity
|
||||||
|
|
@ -94,13 +93,12 @@ class SecurityConfiguration(
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@Profile("dev")
|
|
||||||
fun corsConfigurationSource(): UrlBasedCorsConfigurationSource =
|
fun corsConfigurationSource(): UrlBasedCorsConfigurationSource =
|
||||||
UrlBasedCorsConfigurationSource().apply {
|
UrlBasedCorsConfigurationSource().apply {
|
||||||
registerCorsConfiguration(
|
registerCorsConfiguration(
|
||||||
"/**",
|
"/**",
|
||||||
CorsConfiguration().applyPermitDefaultValues().apply {
|
CorsConfiguration().applyPermitDefaultValues().apply {
|
||||||
allowedOrigins = listOf("http://localhost:8081")
|
allowedOrigins = komgaProperties.cors.allowedOrigins
|
||||||
allowedMethods = HttpMethod.values().map { it.name }
|
allowedMethods = HttpMethod.values().map { it.name }
|
||||||
allowCredentials = true
|
allowCredentials = true
|
||||||
addExposedHeader(HttpHeaders.CONTENT_DISPOSITION)
|
addExposedHeader(HttpHeaders.CONTENT_DISPOSITION)
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,8 @@ komga:
|
||||||
libraries-scan-startup: true
|
libraries-scan-startup: true
|
||||||
database:
|
database:
|
||||||
file: ":memory:"
|
file: ":memory:"
|
||||||
|
cors.allowed-origins:
|
||||||
|
- http://localhost:8081
|
||||||
|
|
||||||
spring:
|
spring:
|
||||||
artemis:
|
artemis:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue