| New file |
| | |
| | | package com.ruoyi.framework.security.filter; |
| | | |
| | | import static org.junit.jupiter.api.Assertions.assertFalse; |
| | | |
| | | import org.junit.jupiter.api.Test; |
| | | |
| | | /** 防止 SSE 异步 dispatch 跳过 JWT 认证,导致实时流刷新后被拒绝。 */ |
| | | class JwtAuthenticationTokenFilterTest |
| | | { |
| | | @Test |
| | | void asyncDispatchMustRestoreAuthenticationContext() |
| | | { |
| | | assertFalse(new JwtAuthenticationTokenFilter().shouldNotFilterAsyncDispatch()); |
| | | } |
| | | } |
| | |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | |
| | | /** SSE 使用异步 dispatch,续传阶段也必须恢复无状态 JWT 上下文。 */ |
| | | @Override |
| | | protected boolean shouldNotFilterAsyncDispatch() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | @Override |
| | | protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) |
| | | throws ServletException, IOException |