11package co.nilin.opex.api.ports.binance.config
22
33import co.nilin.opex.api.core.spi.APIKeyFilter
4- import org.springframework.beans.factory.annotation.Autowired
54import org.springframework.beans.factory.annotation.Value
65import org.springframework.context.annotation.Bean
6+ import org.springframework.context.annotation.Configuration
7+ import org.springframework.security.config.Customizer
78import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity
89import org.springframework.security.config.web.server.SecurityWebFiltersOrder
910import org.springframework.security.config.web.server.ServerHttpSecurity
@@ -14,37 +15,36 @@ import org.springframework.web.reactive.function.client.WebClient
1415import org.springframework.web.server.WebFilter
1516
1617@EnableWebFluxSecurity
17- class SecurityConfig (private val webClient : WebClient ) {
18-
18+ @Configuration
19+ class SecurityConfig (
20+ private val webClient : WebClient ,
21+ private val apiKeyFilter : APIKeyFilter ,
1922 @Value(" \$ {app.auth.cert-url}" )
20- private lateinit var jwkUrl: String
21-
22- @Autowired
23- private lateinit var apiKeyFilter: APIKeyFilter
23+ private val jwkUrl : String
24+ ) {
2425
2526 @Bean
26- fun springSecurityFilterChain (http : ServerHttpSecurity ): SecurityWebFilterChain ? {
27- http.csrf() .disable()
28- .authorizeExchange()
29- .pathMatchers(" /actuator/**" ).permitAll()
30- .pathMatchers(" /swagger-ui/**" ).permitAll()
31- .pathMatchers(" /swagger-resources/**" ).permitAll()
32- .pathMatchers(" /v2/api-docs" ).permitAll()
33- .pathMatchers(" /v3/depth" ).permitAll()
34- .pathMatchers(" /v3/trades" ).permitAll()
35- .pathMatchers(" /v3/ticker/**" ).permitAll()
36- .pathMatchers(" /v3/exchangeInfo" ).permitAll()
37- .pathMatchers(" /v3/currencyInfo/**" ).permitAll()
38- .pathMatchers(" /v3/klines" ).permitAll()
39- .pathMatchers(" /socket" ).permitAll()
40- .pathMatchers(" /v1/landing/**" ).permitAll()
41- .pathMatchers(" /**" ).hasAuthority(" SCOPE_trust" )
42- .anyExchange().authenticated()
43- . and ()
27+ fun springSecurityFilterChain (http : ServerHttpSecurity ): SecurityWebFilterChain {
28+ return http.csrf { it .disable() }
29+ .authorizeExchange {
30+ it .pathMatchers(" /actuator/**" ).permitAll()
31+ .pathMatchers(" /swagger-ui/**" ).permitAll()
32+ .pathMatchers(" /swagger-resources/**" ).permitAll()
33+ .pathMatchers(" /v2/api-docs" ).permitAll()
34+ .pathMatchers(" /v3/depth" ).permitAll()
35+ .pathMatchers(" /v3/trades" ).permitAll()
36+ .pathMatchers(" /v3/ticker/**" ).permitAll()
37+ .pathMatchers(" /v3/exchangeInfo" ).permitAll()
38+ .pathMatchers(" /v3/currencyInfo/**" ).permitAll()
39+ .pathMatchers(" /v3/klines" ).permitAll()
40+ .pathMatchers(" /socket" ).permitAll()
41+ .pathMatchers(" /v1/landing/**" ).permitAll()
42+ .pathMatchers(" /**" ).hasAuthority(" SCOPE_trust" )
43+ .anyExchange().authenticated()
44+ }
4445 .addFilterBefore(apiKeyFilter as WebFilter , SecurityWebFiltersOrder .AUTHENTICATION )
45- .oauth2ResourceServer()
46- .jwt()
47- return http.build()
46+ .oauth2ResourceServer { it.jwt(Customizer .withDefaults()) }
47+ .build()
4848 }
4949
5050 @Bean
0 commit comments