Skip to content

Commit

Permalink
fix : (#29) cors setting
Browse files Browse the repository at this point in the history
  • Loading branch information
coehgns committed Feb 12, 2025
1 parent 30c521c commit 62be160
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class GithubOAuth2LoginConfig {
clientRegistrationRepository: ClientRegistrationRepository,
) {
http
.cors { it.configurationSource(corsConfigurationSource()) }
.csrf { it.disable() }
.oauth2Login { oauth ->
oauth
.successHandler(githubAuthenticationSuccessHandler())
Expand All @@ -41,4 +43,17 @@ class GithubOAuth2LoginConfig {
}
}
}

@Bean
fun corsConfigurationSource(): CorsConfigurationSource {
val configuration = CorsConfiguration()
configuration.allowedOrigins = listOf("*")
configuration.allowedMethods = listOf("*")
configuration.allowedHeaders = listOf("*")
configuration.allowCredentials = true

val source = UrlBasedCorsConfigurationSource()
source.registerCorsConfiguration("/**", configuration)
return source
}
}

0 comments on commit 62be160

Please sign in to comment.