Skip to content

Commit

Permalink
- Make the value of the Access-Control-Allow-Origin response header c…
Browse files Browse the repository at this point in the history
…onfigurable.

- Allow only necessary headers.
  • Loading branch information
yaskovdev committed Aug 10, 2024
1 parent de20242 commit 7fac039
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/main/kotlin/org/motivepick/config/SecurityConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ internal class SecurityConfig {
it.configurationSource {
val configuration = CorsConfiguration()
configuration.allowCredentials = true
configuration.allowedOriginPatterns = listOf("*")
configuration.allowedOriginPatterns = listOf(config.corsAllowedOriginPattern)
configuration.allowedMethods = listOf("GET", "POST", "PUT", "DELETE")
configuration.allowedHeaders = listOf("*")
configuration.allowedHeaders = listOf("Content-Type")
configuration
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/main/kotlin/org/motivepick/config/ServerConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,8 @@ class ServerConfig(
val logoutSuccessUrl: String,

@Value("\${cookie.domain}")
val cookieDomain: String
val cookieDomain: String,

@Value("\${cors.allowedOriginPattern}")
val corsAllowedOriginPattern: String
)
2 changes: 2 additions & 0 deletions src/main/resources/application-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ cookie.domain: milestone.yaskovdev.com
jwt.token:
issuer: https://api.milestone.yaskovdev.com
signing.key: ${JWT_TOKEN_SIGNING_KEY}

cors.allowedOriginPattern: 'https://milestone.yaskovdev.com'
3 changes: 3 additions & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@ authentication.success.url.mobile: 'motive://'

springdoc.packagesToScan: 'org.motivepick'
springdoc.pathsToMatch: '/**'

# This is normally the origin of the Web app or * (if not Prod)
cors.allowedOriginPattern: '*'

0 comments on commit 7fac039

Please sign in to comment.