update 使用 SaStorage 优化 LoginHelper 一级缓存 避免 ThreadLocal 清理不干净问题

This commit is contained in:
疯狂的狮子Li
2022-06-03 00:02:49 +08:00
parent d3ded4162e
commit 088ad1abcc
2 changed files with 6 additions and 32 deletions

View File

@@ -3,21 +3,15 @@ package com.ruoyi.common.security.config;
import cn.dev33.satoken.filter.SaServletFilter;
import cn.dev33.satoken.id.SaIdUtil;
import cn.dev33.satoken.interceptor.SaAnnotationInterceptor;
import cn.dev33.satoken.interceptor.SaRouteInterceptor;
import cn.dev33.satoken.router.SaRouter;
import cn.dev33.satoken.util.SaResult;
import com.ruoyi.common.core.constant.HttpStatus;
import com.ruoyi.common.satoken.utils.LoginHelper;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Sa-Token 整合 jwt (Style模式)
* 权限安全配置
*
* @author Lion Li
*/
@@ -29,18 +23,6 @@ public class SecurityConfiguration implements WebMvcConfigurer {
*/
@Override
public void addInterceptors(InterceptorRegistry registry) {
// 注册路由拦截器,自定义验证规则
// 这里只处理登录缓存清理 具体拦截再网关处理
registry.addInterceptor(new SaRouteInterceptor((request, response, handler) -> {
// 获取所有的
SaRouter.match("/**");
}) {
@SuppressWarnings("all")
@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
LoginHelper.clearCache();
}
}).addPathPatterns("/**");
// 注解拦截器
registry.addInterceptor(new SaAnnotationInterceptor()).addPathPatterns("/**");
}