Spring Security 过滤器链
| Alias | Filter Class | Namespace Element or Attribute |
|---|---|---|
|
CHANNEL_FILTER |
|
|
|
SECURITY_CONTEXT_FILTER |
|
|
|
CONCURRENT_SESSION_FILTER |
|
|
|
HEADERS_FILTER |
|
|
|
CSRF_FILTER |
|
|
|
LOGOUT_FILTER |
|
|
|
X509_FILTER |
|
|
|
PRE_AUTH_FILTER |
|
N/A |
|
CAS_FILTER |
|
N/A |
|
FORM_LOGIN_FILTER |
|
|
|
BASIC_AUTH_FILTER |
|
|
|
SERVLET_API_SUPPORT_FILTER |
|
|
|
JAAS_API_SUPPORT_FILTER |
|
|
|
REMEMBER_ME_FILTER |
|
|
|
ANONYMOUS_FILTER |
|
|
|
SESSION_MANAGEMENT_FILTER |
|
|
|
EXCEPTION_TRANSLATION_FILTER |
|
|
|
FILTER_SECURITY_INTERCEPTOR |
|
|
|
SWITCH_USER_FILTER |
|
N/A |
每个过滤器的作用:
1、SecurityContextPersistenceFilter(SECURITY_CONTEXT_FILTER):请求进来时,创建SecurityContext;请求结束时,清空SecurityContextHolder。
延伸阅读:SecurityContextHolder、SecurityContext、Authentication的区别?
在SecurityContextHolder中我们保存了当前与应用交互的principal数据,Spring Security使用一个Authentication对象来保存和展示这些数据。你不需要自己手工创建一个Authentication对象,而且查询这个对象也相当的简单,
getContext()方法返回的对象是SecurityContext接口的实例,这就是保存在ThreadLocal局部变量中的对象,你可以使用下面的代码(在你的应用的任意位置)获取当前认证用户的姓名信息:
Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
if (principal instanceof UserDetails) {
String username = ((UserDetails)principal).getUsername();
} else {
String username = principal.toString();
}
2、CsrfFilter (CSRF_FILTER):在spring4这个版本中被默认开启的一个过滤器,用于防止csrf攻击
3、LogoutFilter (LOGOUT_FILTER):处理注销请求。参考https://blog.csdn.net/py_xin/article/details/52634880
4、CasAuthenticationFilter(CAS_FILTER):
5、UsernamePasswordAuthenticationFilter(FORM_LOGIN_FILTER):表单提交了username和password,被封装成token进行一系列的认证,便是主要通过这个过滤器完成的,在表单认证的方法中,这是最最关键的过滤器。
6、FilterSecurityInterceptor(FILTER_SECURITY_INTERCEPTOR) : 这个过滤器决定了访问特定路径应该具备的权限,访问的用户的角色,权限是什么?访问的路径需要什么样的角色和权限?这些判断和处理都是由该类进行的。
7、与CAS集成,参考:https://blog.csdn.net/zh350229319/article/details/50517921
8、自定义拦截器,参考:https://blog.csdn.net/chaozhi_guo/article/details/46365735
Spring Security 过滤器链的更多相关文章
- Spring Security过滤器链体系
以下摘自胖哥分享的 2022开工福利教程. 在学习Spring Security的时候你有没有下面这两个疑问: Spring Security的登录是怎么配置的? Spring Security的访问 ...
- spring-security-4 (3)spring security过滤器的创建与注册原理
spring security是通过一个过滤器链来保护你的web应用安全.在spring security中,该过滤链的名称为springSecurityFilterChain,类型为FilterCh ...
- Spring Security学习笔记-自定义Spring Security过滤链
Spring Security使用一系列过滤器处理用户请求,下面是spring-security.xml配置文件. <?xml version="1.0" encoding= ...
- Spring Security 实战干货:图解Spring Security中的Servlet过滤器体系
1. 前言 我在Spring Security 实战干货:内置 Filter 全解析对Spring Security的内置过滤器进行了罗列,但是Spring Security真正的过滤器体系才是我们了 ...
- Spring Security:Servlet 过滤器(三)
3)Servlet 过滤器 Spring Security 过滤器链是一个非常复杂且灵活的引擎.Spring Security 的 Servlet 支持基于 Servlet 过滤器,因此通常首先了解过 ...
- OAuth 2 开发人员指南(Spring security oauth2)
https://github.com/spring-projects/spring-security-oauth/blob/master/docs/oauth2.md 入门 这是支持OAuth2.0的 ...
- SpringBoot + Spring Security 学习笔记(五)实现短信验证码+登录功能
在 Spring Security 中基于表单的认证模式,默认就是密码帐号登录认证,那么对于短信验证码+登录的方式,Spring Security 没有现成的接口可以使用,所以需要自己的封装一个类似的 ...
- Spring Security OAuth 2开发者指南译
Spring Security OAuth 2开发者指南译 介绍 这是用户指南的支持OAuth 2.0.对于OAuth 1.0,一切都是不同的,所以看到它的用户指南. 本用户指南分为两部分,第一部分为 ...
- [转]Spring Security学习总结一
[总结-含源码]Spring Security学习总结一(补命名空间配置) Posted on 2008-08-20 10:25 tangtb 阅读(43111) 评论(27) 编辑 收藏 所属分 ...
随机推荐
- Word Ladder Problem (DFS + BFS)
Given two words (beginWord and endWord), and a dictionary's word list, find the length of shortest t ...
- iOS单利创建的方法
我们在使用单例的时候有两种方法@synchronized,GCD,往往人们使用@synchronized,但是推荐使用GCD: 第一种(@synchronized): + (id)sharedInst ...
- 【week2】 构建之法 读后感及问题
上一次读后感涵盖前五章的内容包括个人技术,结对合作,小组项目等.本周作业的燃尽图以及站立会议是关于<构建之法>第六章的内容,所以关于这一章的读后感涵盖在上两篇博客中. 第七章 MSF 介绍 ...
- HDU 2161 Primes
http://acm.hdu.edu.cn/showproblem.php?pid=2161 Problem Description Write a program to read in a list ...
- mysqlslap工具测试mysql DB的性能
mysqlslap的一个主要工作场景就是对数据库服务器做基准测试. 测试方法 1.测试工具:mysqlslap,mysqlslap是MySQL5.1.4之后自带的benchmark基准测试工具 ...
- JDK各个版本比较 JDK5~JDK9
JDK5 自动装箱与拆箱: 枚举 静态导入,如:import staticjava.lang.System.out 可变参数(Varargs) 内省(Introspector),主要用于操作JavaB ...
- bzoj4760[USACO2017 Jan]Hoof,Paper,Scissors
题意:玩n次剪刀石头布,对方每次出什么已经知道了.你出的招数必须是连续的几段(不能超过k+1段),问你最多赢几次.(n<=100000,k<=20) 正常做法:f[i][j][k]表示前i ...
- Python fileinput模块详解
Python的fileinput模块可以快速对一个或多个文件进行循环遍历. import fileinput for line in fileinput.input(): process(line) ...
- 进程间通讯-2(pipe)
通过pipe 管道的方式也可以实现进程间通信. 父进程和子进程之间可以实现相互通信. from multiprocessing import Process, Pipe def f(conn): co ...
- 【题解】51nod 1685第K大区间2
二分答案+++++++(。・ω・。) 感觉这个思路好像挺常用的:求第\(K\) 大 --> 二分第 \(K\) 大的值 --> 检验当前二分的值排名是第几.前提:排名与数值大小成单调性变化 ...