作者 RuoYi

升级fastjson到最新版2.0.39

@@ -23,7 +23,7 @@ @@ -23,7 +23,7 @@
23 <swagger.version>3.0.0</swagger.version> 23 <swagger.version>3.0.0</swagger.version>
24 <kaptcha.version>2.3.3</kaptcha.version> 24 <kaptcha.version>2.3.3</kaptcha.version>
25 <pagehelper.boot.version>1.4.6</pagehelper.boot.version> 25 <pagehelper.boot.version>1.4.6</pagehelper.boot.version>
26 - <fastjson.version>2.0.34</fastjson.version> 26 + <fastjson.version>2.0.39</fastjson.version>
27 <oshi.version>6.4.4</oshi.version> 27 <oshi.version>6.4.4</oshi.version>
28 <commons.io.version>2.13.0</commons.io.version> 28 <commons.io.version>2.13.0</commons.io.version>
29 <commons.collections.version>3.2.2</commons.collections.version> 29 <commons.collections.version>3.2.2</commons.collections.version>
@@ -130,6 +130,11 @@ public class Constants @@ -130,6 +130,11 @@ public class Constants
130 public static final String LOOKUP_LDAPS = "ldaps:"; 130 public static final String LOOKUP_LDAPS = "ldaps:";
131 131
132 /** 132 /**
  133 + * 自动识别json对象白名单配置(仅允许解析的包名,范围越小越安全)
  134 + */
  135 + public static final String[] JSON_WHITELIST_STR = { "org.springframework", "com.ruoyi" };
  136 +
  137 + /**
133 * 定时任务白名单配置(仅允许访问的包名,如其他需要可以自行添加) 138 * 定时任务白名单配置(仅允许访问的包名,如其他需要可以自行添加)
134 */ 139 */
135 public static final String[] JOB_WHITELIST_STR = { "com.ruoyi" }; 140 public static final String[] JOB_WHITELIST_STR = { "com.ruoyi" };
@@ -6,6 +6,8 @@ import org.springframework.data.redis.serializer.SerializationException; @@ -6,6 +6,8 @@ import org.springframework.data.redis.serializer.SerializationException;
6 import com.alibaba.fastjson2.JSON; 6 import com.alibaba.fastjson2.JSON;
7 import com.alibaba.fastjson2.JSONReader; 7 import com.alibaba.fastjson2.JSONReader;
8 import com.alibaba.fastjson2.JSONWriter; 8 import com.alibaba.fastjson2.JSONWriter;
  9 +import com.alibaba.fastjson2.filter.Filter;
  10 +import com.ruoyi.common.constant.Constants;
9 11
10 /** 12 /**
11 * Redis使用FastJson序列化 13 * Redis使用FastJson序列化
@@ -16,6 +18,8 @@ public class FastJson2JsonRedisSerializer<T> implements RedisSerializer<T> @@ -16,6 +18,8 @@ public class FastJson2JsonRedisSerializer<T> implements RedisSerializer<T>
16 { 18 {
17 public static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8"); 19 public static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8");
18 20
  21 + static final Filter AUTO_TYPE_FILTER = JSONReader.autoTypeFilter(Constants.JSON_WHITELIST_STR);
  22 +
19 private Class<T> clazz; 23 private Class<T> clazz;
20 24
21 public FastJson2JsonRedisSerializer(Class<T> clazz) 25 public FastJson2JsonRedisSerializer(Class<T> clazz)
@@ -43,6 +47,6 @@ public class FastJson2JsonRedisSerializer<T> implements RedisSerializer<T> @@ -43,6 +47,6 @@ public class FastJson2JsonRedisSerializer<T> implements RedisSerializer<T>
43 } 47 }
44 String str = new String(bytes, DEFAULT_CHARSET); 48 String str = new String(bytes, DEFAULT_CHARSET);
45 49
46 - return JSON.parseObject(str, clazz, JSONReader.Feature.SupportAutoType); 50 + return JSON.parseObject(str, clazz, AUTO_TYPE_FILTER);
47 } 51 }
48 } 52 }
@@ -4,6 +4,8 @@ import java.util.HashMap; @@ -4,6 +4,8 @@ import java.util.HashMap;
4 import java.util.Map; 4 import java.util.Map;
5 import java.util.concurrent.TimeUnit; 5 import java.util.concurrent.TimeUnit;
6 import javax.servlet.http.HttpServletRequest; 6 import javax.servlet.http.HttpServletRequest;
  7 +import org.slf4j.Logger;
  8 +import org.slf4j.LoggerFactory;
7 import org.springframework.beans.factory.annotation.Autowired; 9 import org.springframework.beans.factory.annotation.Autowired;
8 import org.springframework.beans.factory.annotation.Value; 10 import org.springframework.beans.factory.annotation.Value;
9 import org.springframework.stereotype.Component; 11 import org.springframework.stereotype.Component;
@@ -29,6 +31,8 @@ import io.jsonwebtoken.SignatureAlgorithm; @@ -29,6 +31,8 @@ import io.jsonwebtoken.SignatureAlgorithm;
29 @Component 31 @Component
30 public class TokenService 32 public class TokenService
31 { 33 {
  34 + private static final Logger log = LoggerFactory.getLogger(TokenService.class);
  35 +
32 // 令牌自定义标识 36 // 令牌自定义标识
33 @Value("${token.header}") 37 @Value("${token.header}")
34 private String header; 38 private String header;
@@ -72,6 +76,7 @@ public class TokenService @@ -72,6 +76,7 @@ public class TokenService
72 } 76 }
73 catch (Exception e) 77 catch (Exception e)
74 { 78 {
  79 + log.error("获取用户信息异常'{}'", e.getMessage());
75 } 80 }
76 } 81 }
77 return null; 82 return null;