Spring-security-oauth2 与 Spring-
spring security 认证流程:

spring security 权限校验流程:

以上流程图源自:
http://www.spring4all.com/article/439
http://www.spring4all.com/article/458
关键的类和接口介绍:
AbstractAuthenticationProcessingFilter 类:在不同maven包下的展现形式:
spring-boot-starter-security包下:

spring-security-oauth2包下:


可以看出多了一个OAuth2ClientAuthenticationProcessingFilter和ClientCredentialsTokenEndpointFilter;
当使用Oauth2认证时,主要走的两个Filter;
AuthenticationManager 接口:认证时主要是PrividerManager 实现类去做认证;

PrividerManager 实现类中主要的方法和属性介绍:
认证器集合:providers

authenticate 方法:

1. 遍历认证器.
2.判断认证器是否支持token的认证
3.如果支持,进行具体的认证逻辑
AuthenticationProvider 接口:

AbstractUserDetailsAuthenticationProvider 抽象类:
authenticate 方法:

子类实现retrieveUser 方法,通过不同的方式获取UserDetails;
DaoAuthenticationProvider 实现类(去实现retrieveUser ):
retrieveUser方法:

通过UserDetailsService 对象获取UserDetails对象;
UserDetailsService 属性:

UserDetailsService 接口:
spring-boot-starter-security包下:

spring-security-oauth2包下:

可以看出在spring-security-oauth2包下多一个ClientDetailsUserDetailsService类,这个也就是spring security实现Oauth2的主要认证类;