spring security理解
2019-09-15 00:38 Spiderman25 阅读(81) 评论(0) 收藏 举报1默认所有的都拦截
2WebSecurityConfig即可
加@Configuration
@EnableWebSecurity
3在启动类加@EnableGlobalMethodSecurity可以支持注解
4在configure(HttpSecurity http)中配上登录注销页以及csrf、哪些可访问、哪些不可访问
登录页可以设置登录页路径、成功路径、失败路径以及处理登录的路径,在login页面中用户为username密码password,action为处理登录的路径。
5在configure(AuthenticationManagerBuilder auth)中配UserServiceDetail,在UserServiceDetail中可以抛出异常给登录错误页接收,也可以在自定义的AuthenticationFailureHandler中接收
6
AccessDeniedHandler:用来解决匿名用户访问无权限资源时的异常
AuthenticationEntryPoint:用来解决认证过的用户访问无权限资源时的异常
均在configure(HttpSecurity http)中配
7
AuthenticationSuccessHandler
AuthenticationFailureHandler:https://majing.io/posts/10000040281162
均在configure(HttpSecurity http)中配
可参考https://blog.csdn.net/shuangyueliao/article/details/87978212
浙公网安备 33010602011771号