problems injecting custom userDetailsService in Spring Security OAuth2

前端 未结 3 864
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-22 05:33

I am using Spring Security OAuth2 2.0.7.RELEASE. As i am using ORM to connect to my database and default JdbcUserDetailsManager uses jdbc i wanted to implement my own UserDetail

3条回答
  •  走了就别回头了
    2021-01-22 06:02

    You are using auth.jdbcAuthentication().dataSource(this.dataSource).and().userDetailsService(‌​this.userService);// Inject custom and I here it's creating two auth managers - one with default JdbcDaoImpl and dataSource pointing to this.dataSource and another with your custom userService. Try just putting auth.userDetailsService(this.userService) (I hope that userService already have jdbc autowired inside).

    The point here is that .and() is used to add different authentication configurations to the authentication manager, not configuring the jdbcAuthentication() one.

提交回复
热议问题