spring security 5.x 使用及分析(三:自定义配置—登录配置及原理)

spring security 5.x 使用及分析(三:自定义配置—原理解析)

    • 1.1 、分析原理

1.1 、分析原理

代码中配置密码加密方式为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 UserDetails
	 * 
	 */
	UserDetails loadUserByUsername(String username) throws UsernameNotFoundException;
}

这个接口里只用一个loadUserByUsername()方法,这个注释可以看到,这个方法通过具体实现,可以根据username查找到用户;

你可能感兴趣的:(spring,security,spring,security)