spring security 5.x 使用及分析(三:自定义配置—oauth2原理解析)
本文个人博客地址:https://www.abeille.top/blog/detail/AT829RI12
配置密码加密方式为BCryptPassworncoder,关于这个BCryptPasswordEncoder加密方式的介绍,请自行查询;代码中使用构造注入了UserDetailsService的接口,实现指向了UserDetailsServiceImpl,这个是UserDetailsService接口的具体实现,UserDetailsService接口是Spring Security提供的,我们看一下这个借口的源码:
public interface UserDetailsService {
/**
* Locates the user based on the username. In the actual implementation, the search
* may possibly be case sensitive, or case insensitive depending on how the
* implementation instance is configured. In this case, the <code>UserDetails</code>
*
*/
UserDetails loadUserByUsername(String username) throws UsernameNotFoundException;
}
这个接口里只用一个loadUserByUsername()方法,这个注释可以看到,这个方法通过具体实现,可以根据username查找到用户;
这个接口的实现:
/**
* 用户认证service实现
*
* @author liwenqiang 2018/10/18 21:18
**/
@Service