客户端发起一个请求,进入 Security 过滤器链。html
当到 LogoutFilter 的时候判断是不是登出路径,若是是登出路径则到 logoutHandler ,若是登出成功则到 logoutSuccessHandler 登出成功处理,若是登出失败则由 ExceptionTranslationFilter ;若是不是登出路径则直接进入下一个过滤器。java
当到 UsernamePasswordAuthenticationFilter 的时候判断是否为登陆路径,若是是,则进入该过滤器进行登陆操做,若是登陆失败则到 AuthenticationFailureHandler 登陆失败处理器处理,若是登陆成功则到 AuthenticationSuccessHandler 登陆成功处理器处理,若是不是登陆请求则不进入该过滤器。spring
当到 FilterSecurityInterceptor 的时候会拿到 uri ,根据 uri 去找对应的鉴权管理器,鉴权管理器作鉴权工做,鉴权成功则到 Controller 层不然到 AccessDeniedHandler 鉴权失败处理器处理。安全
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency>
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-oauth2</artifactId> </dependency>
@RestController public class Hello { @RequestMapping("/hello") public String hello(){ return "hello spring security"; } }