spring-boot icon indicating copy to clipboard operation
spring-boot copied to clipboard

Custom ClientDetailsService not picked up by auto-configuration

Open bassemZohdy opened this issue 10 years ago • 6 comments

In OAuth2AuthorizationServerConfiguration it is auto-wiring BaseClientDetails but not search for ClientDetailsService in context, so it check for ClientDetailsService first and if its there should be used instead of creating in-memory one.

bassemZohdy avatar Oct 04 '16 12:10 bassemZohdy

Rather than creating an issue with what you think the code is doing, could you please explain what you're trying to do and how the current auto-configuration does not fit? A sample project would be ideal.

snicoll avatar Oct 04 '16 13:10 snicoll

OK, I faced an issue when I tried to use JdbcClientDetailsService that I was creating ClientDetailsService bean with @Bean in main Spring boot configuration class, but I found that the Auto configuration not using my ClientDetailsService bean and instead it is creating in-memory with properties from application.properties and if it is not there it is generating client and use it.

what am thinking about that the Auto configuration have to search for ClientDetailsService in context if it is there have to use it, and if there is no ClientDetailsService it is OK to create in-memory one.

bassemZohdy avatar Oct 04 '16 13:10 bassemZohdy

The behaviour is working as advertized. I'd assume that you should define a AuthorizationServerConfigurer bean instead.

What do you think @dsyer ?

snicoll avatar Oct 04 '16 13:10 snicoll

sure I can make my own AuthorizationServerConfigurer and this way am using to work around it, but if we checked Spring-security project for example, if you create a UserDetailsService in context the Auto-configuration is using it, so I was expecting the same behavior.

bassemZohdy avatar Oct 04 '16 14:10 bassemZohdy

Yeah, works as designed, but maybe some room for improvement in the design. (Autowiring UserDetailsService is a recent thing in spring security, by the way.)

dsyer avatar Oct 04 '16 21:10 dsyer

Boot's own OAuth support has been removed in 2.0 in favour of the OAuth support that's coming in Spring Security 5.x

wilkinsona avatar Sep 27 '17 13:09 wilkinsona