Spring Security(Third Edition)
上QQ阅读APP看书,第一时间看更新

Configuring UserDetailsService

Now that we have a new UserDetailsService object, let's update the Spring Security configuration to utilize it. Our CalendarUserDetailsService class is added to our Spring configuration automatically, since we leverage classpath scanning and the @Component annotation. This means we only need to update Spring Security to refer to the CalendarUserDetailsService class we just created. We are also able to remove the configure() and userDetailsService() methods, Spring Security's in-memory implementation of UserDetailsService, since we are now providing our own UserDetailsService implementation. Update the SecurityConfig.java file, as follows:

//src/main/java/com/packtpub/springsecurity/configuration/SecurityConfig.java

@Override
public void configure(AuthenticationManagerBuilder auth) throws Exception {
...
}
@Bean
@Override
public UserDetailsManager userDetailsService() {
...
}