在反应式编程模型中注册自定义AuthenticationProvider

时间:2018-07-24 15:54:36

标签: spring-boot spring-security spring-webflux

我正在尝试注册自己的AuthenticationProvider

我的配置:

@EnableWebFluxSecurity
class SecurityConfig {

  @Bean
  fun customAuthenticationProvider(): CustomAuthenticationProvider {
    return CustomAuthenticationProvider()
  }

  @Bean
  fun securityWebFilterChain(http: ServerHttpSecurity): SecurityWebFilterChain {
    return http.authorizeExchange()
        .anyExchange().authenticated()
        .and().build()
  }
}

但是由于我使用webflux,所以无法使用WebSecurityConfigurerAdapter

启用这种AuthenticationProvider的正确方法是什么?

1 个答案:

答案 0 :(得分:1)

好的,我已经找到答案-我需要注册ReactiveAuthenticationManager类型的Bean。来源:https://github.com/spring-projects/spring-security/issues/5565

相关问题