以下是Spring Security中一些默认的Filter,按照它们在Filter Chain中的顺序排列:
| 顺序 | Filter类名 | 描述 |
|---|---|---|
| 1 | ChannelProcessingFilter | 确保请求通过正确的通道(如HTTP或HTTPS)。 |
| 2 | WebAsyncManagerIntegrationFilter | 集成Spring的WebAsyncManager,用于异步请求处理。 |
| 3 | SecurityContextPersistenceFilter | 在请求之间持久化和恢复SecurityContext。 |
| 4 | HeaderWriterFilter | 向响应中添加安全相关的HTTP头。 |
| 5 | CorsFilter | 处理跨域资源共享(CORS)请求。 |
| 6 | CsrfFilter | 防止跨站请求伪造(CSRF)攻击。 |
| 7 | LogoutFilter | 处理用户注销请求。 |
| 8 | OAuth2AuthorizationRequestRedirectFilter | 处理OAuth2授权请求的重定向。 |
| 9 | Saml2WebSsoAuthenticationRequestFilter | 处理SAML2 Web SSO认证请求。 |
| 10 | X509AuthenticationFilter | 处理基于X.509证书的认证。 |
| 11 | AbstractPreAuthenticatedProcessingFilter | 处理预认证请求的基类。 |
| 12 | CasAuthenticationFilter | 处理CAS认证请求。 |
| 13 | OAuth2LoginAuthenticationFilter | 处理OAuth2登录认证请求。 |
| 14 | Saml2WebSsoAuthenticationFilter | 处理SAML2 Web SSO认证请求。 |
| 15 | UsernamePasswordAuthenticationFilter | 处理基于用户名和密码的表单登录请求。 |
| 16 | OpenIDAuthenticationFilter | 处理OpenID认证请求。 |
| 17 | DefaultLoginPageGeneratingFilter | 生成默认的登录页面。 |
| 18 | DefaultLogoutPageGeneratingFilter | 生成默认的注销页面。 |
| 19 | ConcurrentSessionFilter | 确保用户的并发会话数不超过限制。 |
| 20 | DigestAuthenticationFilter | 处理HTTP摘要认证请求。 |
| 21 | BearerTokenAuthenticationFilter | 处理基于Bearer Token的认证请求。 |
| 22 | BasicAuthenticationFilter | 处理HTTP基本认证请求。 |
| 23 | RequestCacheAwareFilter | 恢复缓存的请求,用于在认证成功后重定向到原始请求。 |
| 24 | SecurityContextHolderAwareRequestFilter | 包装请求对象,使其支持Servlet API的安全方法。 |
| 25 | JaasApiIntegrationFilter | 集成JAAS(Java认证和授权服务)。 |
| 26 | RememberMeAuthenticationFilter | 处理“记住我”功能的认证请求。 |
| 27 | AnonymousAuthenticationFilter | 为未认证的用户分配一个匿名身份。 |
| 28 | OAuth2AuthorizationCodeGrantFilter | 处理OAuth2授权码授予流程。 |
| 29 | SessionManagementFilter | 管理用户会话,包括会话固定保护。 |
| 30 | ExceptionTranslationFilter | 处理安全相关的异常,如AccessDeniedException和AuthenticationException。 |
| 31 | FilterSecurityInterceptor | 执行安全拦截,决定是否允许请求继续。 |
| 32 | SwitchUserFilter | 允许管理员切换为用户身份。 |
这些Filter按照顺序组成Spring Security的Filter Chain,每个Filter都有特定的职责。根据配置的不同,某些Filter可能会被启用或禁用。
