Skip to content
This repository was archived by the owner on Mar 30, 2025. It is now read-only.

Commit 07b2548

Browse files
committed
replace deprecated method
1 parent 1142249 commit 07b2548

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

adapter/src/main/kotlin/org/railwaystations/rsapi/adapter/web/auth/WebSecurityConfig.kt

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,24 @@ class WebSecurityConfig(
6363
@Order(1)
6464
@Profile("!mockMvcTest")
6565
fun oauthFilterChain(http: HttpSecurity): SecurityFilterChain {
66-
OAuth2AuthorizationServerConfiguration.applyDefaultSecurity(http)
66+
val authorizationServerConfigurer = OAuth2AuthorizationServerConfigurer.authorizationServer()
6767
http
68+
.with(authorizationServerConfigurer) {
69+
it.oidc(withDefaults())
70+
.authorizationEndpoint { authorizationEndpoint -> authorizationEndpoint.consentPage("/oauth2/consent") }
71+
}
72+
.authorizeHttpRequests { authorize ->
73+
authorize.anyRequest().authenticated()
74+
}
6875
.securityMatcher("/oauth2/**")
6976
.cors { corsConfigurer ->
7077
corsConfigurer.configurationSource {
71-
val cors = CorsConfiguration()
72-
cors.setAllowedOriginPatterns(listOf("*"))
73-
cors.allowedMethods = listOf("GET", "POST", "OPTIONS")
74-
cors.allowedHeaders = listOf("Authorization")
75-
cors.allowCredentials = true
76-
cors
78+
CorsConfiguration().apply {
79+
allowedOriginPatterns = listOf("*")
80+
allowedMethods = listOf("GET", "POST", "OPTIONS")
81+
allowedHeaders = listOf("Authorization")
82+
allowCredentials = true
83+
}
7784
}
7885
}
7986
.exceptionHandling { exceptions ->
@@ -83,9 +90,6 @@ class WebSecurityConfig(
8390
)
8491
}
8592
.oauth2ResourceServer { serverConfigurer -> serverConfigurer.jwt(withDefaults()) }
86-
.getConfigurer(OAuth2AuthorizationServerConfigurer::class.java)
87-
.oidc(withDefaults())
88-
.authorizationEndpoint { authorizationEndpoint -> authorizationEndpoint.consentPage("/oauth2/consent") }
8993

9094
return http.build()
9195
}

0 commit comments

Comments
 (0)