Spring Boot [集成-Spring Security]-(登录校验方式)

1、spring security认证过程:

Spring Security认证是由 AuthenticationManager 来管理的,但是真正进行认证的是 AuthenticationManager 中定义的 AuthenticationProvider。

AuthenticationManager 中可以定义有多个 AuthenticationProvider。当我们使用 authentication-provider 元素来定义一个 AuthenticationProvider 时,如果没有指定对应关联的 AuthenticationProvider 对象。

Spring Security 默认会使用 DaoAuthenticationProvider。DaoAuthenticationProvider 在进行认证的时候需要一个 UserDetailsService 来获取用户的信息 UserDetails,其中包括用户名、密码和所拥有的权限等。

所以如果我们需要改变认证的方式,我们可以实现自己的 AuthenticationProvider;如果需要改变认证的用户信息来源,我们可以实现 UserDetailsService。

仅做笔记,如有不好的地方也可多多指教。

详情请查看:https://segmentfault.com/a/1190000008893479

AuthenticationManager 与UserDetailsService结合使用的demo:https://gitee.com/hong_ej/SpringSecurity.git



猜你喜欢

转载自blog.csdn.net/baidu_28068985/article/details/79707546