Spring boot UserDetails服务被安全配置忽略
我已经尝试了spring webFlux的安全配置,如文档中所述: 安全配置忽略userDetailsServiceBean-我无法使用user:pass登录,但可以使用自动配置的凭据登录Spring boot UserDetails服务被安全配置忽略,spring-boot,spring-security,spring-webflux,Spring Boot,Spring Security,Spring Webflux,我已经尝试了spring webFlux的安全配置,如文档中所述: 安全配置忽略userDetailsServiceBean-我无法使用user:pass登录,但可以使用自动配置的凭据登录 UserDetailsServiceAutoConfiguration: 2019-04-22 11:29:24.571 INFO 12343 --- [ main] .s.s.UserDetailsServiceAutoConfiguration : Using generate
UserDetailsServiceAutoConfiguration:
2019-04-22 11:29:24.571 INFO 12343 --- [ main] .s.s.UserDetailsServiceAutoConfiguration :
Using generated security password: ff00a80a-d810-43d6-9c89-e861eb1bed96
My pom.xml(片段):
@EnableWebSecurity
注释。它用于Servlet应用程序,不应用于WebFlux@Bean
public ReactiveAuthenticationManager authenticationManager(ReactiveUserDetailsService detailsService) {
return new UserDetailsRepositoryReactiveAuthenticationManager(detailsService);
}
在您的情况下,最有可能的是,@EnableWebSecurity
注释在memoryuserdetailsmanager中配置类型为的bean,它是ReactiveUserDetailsManager
的非反应性变体
注意:如果仅计划使用WebFlux,则可以从POM中删除以下内容:spring boot starter tomcat
和spring boot starter web
删除@EnableWebSecurity
注释。它用于Servlet应用程序,不应用于WebFlux
<> >您也可以考虑在WebFLUX配置中定义一个类型为bean的bean > UsDebug IsRealTyrRyActudieAudioCudialMeals/Cuth>;例如:
@Bean
public ReactiveAuthenticationManager authenticationManager(ReactiveUserDetailsService detailsService) {
return new UserDetailsRepositoryReactiveAuthenticationManager(detailsService);
}
在您的情况下,最有可能的是,@EnableWebSecurity
注释在memoryuserdetailsmanager
中配置类型为的bean,它是ReactiveUserDetailsManager
的非反应性变体
注意:如果仅计划使用WebFlux,则可以从POM中删除以下内容:spring boot starter tomcat
和spring boot starter web
1。“删除@EnableWebSecurity注释”-无影响2。“您也可以考虑定义一个bean类型的用户详细信息库。排除依赖项org.springframework.boot spring boot starter web-work。问题更新:如果我想在一个应用程序中使用spring web mvc和spring webflux,如何配置安全性(稍后我将尝试使用两种安全配置—一种用于web mvc,另一种用于webflux)?1。“删除@EnableWebSecurity注释”-无影响2。“您也可以考虑定义一个bean类型的用户详细信息库。排除依赖项org.springframework.boot spring boot starter web-work。问题更新:如果我想在一个应用程序中使用SpringWebMVC和SpringWebFlux,如何配置安全性(稍后我将尝试使用两种安全配置—一种用于WebMVC,另一种用于webflux)?
@Bean
public ReactiveAuthenticationManager authenticationManager(ReactiveUserDetailsService detailsService) {
return new UserDetailsRepositoryReactiveAuthenticationManager(detailsService);
}