作者 朱兆平

update: 安全检测报告后优化及修复

正在显示 24 个修改的文件 包含 128 行增加206 行删除
@@ -51,7 +51,7 @@ spring: @@ -51,7 +51,7 @@ spring:
51 enabled: true 51 enabled: true
52 52
53 datasource: 53 datasource:
54 - type: com.alibaba.druid.pool.DruidDataSource 54 + type: com.zaxxer.hikari.HikariDataSource
55 #oracle 55 #oracle
56 #driver-class-name=oracle.jdbc.OracleDriver 56 #driver-class-name=oracle.jdbc.OracleDriver
57 #url=jdbc:oracle:thin:@10.50.3.68:1521:CGODW 57 #url=jdbc:oracle:thin:@10.50.3.68:1521:CGODW
@@ -63,29 +63,25 @@ spring: @@ -63,29 +63,25 @@ spring:
63 password: QAHqCJf2kFYCLirM 63 password: QAHqCJf2kFYCLirM
64 driver-class-name: com.mysql.cj.jdbc.Driver 64 driver-class-name: com.mysql.cj.jdbc.Driver
65 #配置初始化大小/最小/最大 65 #配置初始化大小/最小/最大
66 - druid:  
67 - initial-size: 1  
68 - min-idle: 1  
69 - max-active: 20  
70 - #获取连接等待超时时间  
71 - max-wait: 60000  
72 - #一个连接在池中最小生存的时间  
73 - min-evictable-idle-time-millis: 300000  
74 - #间隔多久进行一次检测,检测需要关闭的空闲连接  
75 - time-between-eviction-runs-millis: 60000  
76 - #mysql  
77 - validation-query: SELECT 1 FROM DUAL  
78 - #oracle  
79 - #druid.validation-query:SELECT 'x' FROM DUAL  
80 - test-while-idle: true  
81 - test-on-borrow: false  
82 - test-on-return: false  
83 - default-auto-commit: true  
84 -# tomcat:  
85 -# max-wait: 10  
86 -# max-idle: 10000  
87 -# min-idle: 5  
88 -# initial-size: 5 66 + hikari:
  67 + # 连接池名称
  68 + pool-name: UserCenterHikariCP-
  69 + # 最小空闲连接数
  70 + minimum-idle: 1
  71 + # 最大连接数
  72 + maximum-pool-size: 20
  73 + # 连接超时时间(毫秒)
  74 + connection-timeout: 60000
  75 + # 空闲连接超时时间(毫秒)
  76 + idle-timeout: 300000
  77 + # 连接测试超时时间
  78 + validation-timeout: 3000
  79 + # 连接最大生命周期
  80 + max-lifetime: 1800000
  81 + # 连接测试查询
  82 + connection-test-query: SELECT 1 FROM DUAL
  83 + # 初始化连接数
  84 + initialization-fail-timeout: 1
89 85
90 eureka: 86 eureka:
91 instance: 87 instance:
@@ -96,11 +92,7 @@ eureka: @@ -96,11 +92,7 @@ eureka:
96 hostname: ${spring.cloud.client.ip-address} 92 hostname: ${spring.cloud.client.ip-address}
97 lease-renewal-interval-in-seconds: 15 93 lease-renewal-interval-in-seconds: 15
98 lease-expiration-duration-in-seconds: 45 94 lease-expiration-duration-in-seconds: 45
99 - health-check-url-path: /actuator/health  
100 - metadata-map:  
101 - user:  
102 - name: "admin" #These two are needed so that the server  
103 - password: "123456" 95 + health-check-url-path: /ac/health
104 client: 96 client:
105 #eureka注册中心服务器地址 97 #eureka注册中心服务器地址
106 service-url: 98 service-url:
@@ -108,19 +100,26 @@ eureka: @@ -108,19 +100,26 @@ eureka:
108 defaultZone: http://tianbo_cgo:vmvnv1v2@192.168.1.53:12345/eureka/ 100 defaultZone: http://tianbo_cgo:vmvnv1v2@192.168.1.53:12345/eureka/
109 registry-fetch-interval-seconds: 30 101 registry-fetch-interval-seconds: 30
110 102
111 -  
112 -  
113 management: 103 management:
114 endpoints: 104 endpoints:
115 enabled-by-default: true 105 enabled-by-default: true
116 web: 106 web:
  107 + base-path: /ac # 端点路径更改为 /ac
117 exposure: 108 exposure:
118 - include: "*" 109 + include: "health,info" # 仅暴露必要端点
119 endpoint: 110 endpoint:
120 health: 111 health:
121 - show-details: always 112 + show-details: never # 不显示详细健康信息
122 shutdown: 113 shutdown:
123 - enabled: true 114 + enabled: false # 禁用关闭端点
  115 + env:
  116 + enabled: false # 禁用环境端点(防止敏感信息泄露)
  117 + mappings:
  118 + enabled: false # 禁用映射端点(防止接口路径泄露)
  119 + beans:
  120 + enabled: false # 禁用beans端点
  121 + configprops:
  122 + enabled: false # 禁用configprops端点
124 123
125 mybatis: 124 mybatis:
126 mapper-locations: classpath:mapping/*.xml 125 mapper-locations: classpath:mapping/*.xml
@@ -6,19 +6,19 @@ @@ -6,19 +6,19 @@
6 <parent> 6 <parent>
7 <groupId>org.springframework.boot</groupId> 7 <groupId>org.springframework.boot</groupId>
8 <artifactId>spring-boot-starter-parent</artifactId> 8 <artifactId>spring-boot-starter-parent</artifactId>
9 - <version>2.1.9.RELEASE</version> 9 + <version>2.7.18</version>
10 <relativePath/> <!-- lookup parent from repository --> 10 <relativePath/> <!-- lookup parent from repository -->
11 </parent> 11 </parent>
12 <groupId>com.tianbo</groupId> 12 <groupId>com.tianbo</groupId>
13 <artifactId>cloud-user-center</artifactId> 13 <artifactId>cloud-user-center</artifactId>
14 - <version>5.1.2Beta-DataPermission</version> 14 + <version>5.2.2Beta-DataPermission</version>
15 <name>usercenter</name> 15 <name>usercenter</name>
16 <description>usercenter for springcloud</description> 16 <description>usercenter for springcloud</description>
17 17
18 <properties> 18 <properties>
19 <java.version>1.8</java.version> 19 <java.version>1.8</java.version>
20 - <spring-cloud.version>Greenwich.SR3</spring-cloud.version>  
21 - <fastjson_version>1.2.28</fastjson_version> 20 + <spring-cloud.version>2021.0.8</spring-cloud.version>
  21 + <fastjson_version>2.0.60</fastjson_version>
22 <lombok_sersion>1.18.6</lombok_sersion> 22 <lombok_sersion>1.18.6</lombok_sersion>
23 <swagger2_version>2.9.2</swagger2_version> 23 <swagger2_version>2.9.2</swagger2_version>
24 <shiro.version>1.2.5</shiro.version> 24 <shiro.version>1.2.5</shiro.version>
@@ -36,6 +36,12 @@ @@ -36,6 +36,12 @@
36 <artifactId>mybatis-spring-boot-starter</artifactId> 36 <artifactId>mybatis-spring-boot-starter</artifactId>
37 <version>2.2.2</version> 37 <version>2.2.2</version>
38 </dependency> 38 </dependency>
  39 + <dependency>
  40 + <groupId>jakarta.validation</groupId>
  41 + <artifactId>jakarta.validation-api</artifactId>
  42 + <version>2.0.2</version>
  43 + <scope>compile</scope>
  44 + </dependency>
39 <!--<dependency>--> 45 <!--<dependency>-->
40 <!--<groupId>org.springframework.boot</groupId>--> 46 <!--<groupId>org.springframework.boot</groupId>-->
41 <!--<artifactId>spring-boot-devtools</artifactId>--> 47 <!--<artifactId>spring-boot-devtools</artifactId>-->
@@ -45,16 +51,6 @@ @@ -45,16 +51,6 @@
45 <!--有WEBSOCKET包 包含了spring-boot-starter-web 和spring-boot-starter包 有这个包不要引入这俩包--> 51 <!--有WEBSOCKET包 包含了spring-boot-starter-web 和spring-boot-starter包 有这个包不要引入这俩包-->
46 <dependency> 52 <dependency>
47 <groupId>org.springframework.boot</groupId> 53 <groupId>org.springframework.boot</groupId>
48 - <artifactId>spring-boot-starter-websocket</artifactId>  
49 - <exclusions>  
50 - <exclusion>  
51 - <groupId>org.springframework.boot</groupId>  
52 - <artifactId>spring-boot-starter</artifactId>  
53 - </exclusion>  
54 - </exclusions>  
55 - </dependency>  
56 - <dependency>  
57 - <groupId>org.springframework.boot</groupId>  
58 <artifactId>spring-boot-starter-data-redis</artifactId> 54 <artifactId>spring-boot-starter-data-redis</artifactId>
59 </dependency> 55 </dependency>
60 <dependency> 56 <dependency>
@@ -93,62 +89,46 @@ @@ -93,62 +89,46 @@
93 <artifactId>spring-boot-starter-test</artifactId> 89 <artifactId>spring-boot-starter-test</artifactId>
94 <scope>test</scope> 90 <scope>test</scope>
95 </dependency> 91 </dependency>
  92 + <!-- junit -->
96 <dependency> 93 <dependency>
97 - <groupId>org.springframework.boot</groupId>  
98 - <artifactId>spring-boot-starter-web</artifactId>  
99 - <exclusions>  
100 - <exclusion>  
101 - <groupId>ch.qos.logback</groupId>  
102 - <artifactId>logback-classic</artifactId>  
103 - </exclusion>  
104 - </exclusions> 94 + <groupId>junit</groupId>
  95 + <artifactId>junit</artifactId>
  96 + <version>4.13.2</version>
  97 + <scope>test</scope>
105 </dependency> 98 </dependency>
106 -  
107 - <!--spring boot-->  
108 - <!-- tools-->  
109 - <!--集成swagger2,下面两个spring的配置解决springboot包 与swagger2的包冲突问题,生产部署的时候记得要去掉此swagger2的配置,开发环境开启-->  
110 - <!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger-ui -->  
111 <dependency> 99 <dependency>
112 - <groupId>org.springframework.plugin</groupId>  
113 - <artifactId>spring-plugin-core</artifactId>  
114 - <version>1.2.0.RELEASE</version><!--$NO-MVN-MAN-VER$--> 100 + <groupId>org.junit.jupiter</groupId>
  101 + <artifactId>junit-jupiter-api</artifactId>
  102 + <version>5.9.3</version>
  103 + <scope>test</scope>
115 </dependency> 104 </dependency>
116 <dependency> 105 <dependency>
117 - <groupId>org.springframework.plugin</groupId>  
118 - <artifactId>spring-plugin-metadata</artifactId>  
119 - <version>1.2.0.RELEASE</version><!--$NO-MVN-MAN-VER$--> 106 + <groupId>org.springframework.boot</groupId>
  107 + <artifactId>spring-boot-starter-web</artifactId>
120 </dependency> 108 </dependency>
121 <dependency> 109 <dependency>
122 - <groupId>io.springfox</groupId>  
123 - <artifactId>springfox-swagger-ui</artifactId>  
124 - <version>${swagger2_version}</version>  
125 - <exclusions>  
126 - <exclusion>  
127 - <groupId>org.springframework.plugin</groupId>  
128 - <artifactId>spring-plugin-core</artifactId>  
129 - </exclusion>  
130 - <exclusion>  
131 - <groupId>org.springframework.plugin</groupId>  
132 - <artifactId>spring-plugin-metadata</artifactId>  
133 - </exclusion>  
134 - </exclusions> 110 + <groupId>org.springframework.boot</groupId>
  111 + <artifactId>spring-boot-starter-aop</artifactId>
135 </dependency> 112 </dependency>
  113 + <!--spring boot-->
  114 + <!-- tools-->
  115 + <!--集成swagger2,下面两个spring的配置解决springboot包 与swagger2的包冲突问题,生产部署的时候记得要去掉此swagger2的配置,开发环境开启-->
  116 + <!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger-ui -->
  117 +<!-- <dependency>-->
  118 +<!-- <groupId>org.springframework.plugin</groupId>-->
  119 +<!-- <artifactId>spring-plugin-core</artifactId>-->
  120 +<!-- <version>1.2.0.RELEASE</version>&lt;!&ndash;$NO-MVN-MAN-VER$&ndash;&gt;-->
  121 +<!-- </dependency>-->
  122 +<!-- <dependency>-->
  123 +<!-- <groupId>org.springframework.plugin</groupId>-->
  124 +<!-- <artifactId>spring-plugin-metadata</artifactId>-->
  125 +<!-- <version>1.2.0.RELEASE</version>&lt;!&ndash;$NO-MVN-MAN-VER$&ndash;&gt;-->
  126 +<!-- </dependency>-->
136 <!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger2 --> 127 <!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger2 -->
137 <dependency> 128 <dependency>
138 <groupId>io.springfox</groupId> 129 <groupId>io.springfox</groupId>
139 <artifactId>springfox-swagger2</artifactId> 130 <artifactId>springfox-swagger2</artifactId>
140 <version>${swagger2_version}</version> 131 <version>${swagger2_version}</version>
141 - <!--2.9.2集成的是M1的这两个包,跟现在用的Greenwich.BUILD-SNAPSHOT的版本的SPRING boot2的版本包有冲突。去掉-->  
142 - <exclusions>  
143 - <exclusion>  
144 - <groupId>org.springframework.plugin</groupId>  
145 - <artifactId>spring-plugin-core</artifactId>  
146 - </exclusion>  
147 - <exclusion>  
148 - <groupId>org.springframework.plugin</groupId>  
149 - <artifactId>spring-plugin-metadata</artifactId>  
150 - </exclusion>  
151 - </exclusions>  
152 </dependency> 132 </dependency>
153 <!--集成swagger2--> 133 <!--集成swagger2-->
154 <!-- https://mvnrepository.com/artifact/org.projectlombok/lombok --> 134 <!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
@@ -164,21 +144,17 @@ @@ -164,21 +144,17 @@
164 <version>1.11</version> 144 <version>1.11</version>
165 </dependency> 145 </dependency>
166 <dependency> 146 <dependency>
167 - <groupId>com.alibaba</groupId>  
168 - <artifactId>fastjson</artifactId> 147 + <groupId>com.alibaba.fastjson2</groupId>
  148 + <artifactId>fastjson2</artifactId>
169 <version>${fastjson_version}</version> 149 <version>${fastjson_version}</version>
170 </dependency> 150 </dependency>
171 <!-- tools--> 151 <!-- tools-->
172 - <!-- alibaba的druid数据库连接池 -->  
173 - <dependency>  
174 - <groupId>com.alibaba</groupId>  
175 - <artifactId>druid-spring-boot-starter</artifactId>  
176 - <version>1.1.9</version>  
177 - </dependency>  
178 <!-- mysql--> 152 <!-- mysql-->
179 <dependency> 153 <dependency>
180 - <groupId>mysql</groupId>  
181 - <artifactId>mysql-connector-java</artifactId> 154 + <groupId>com.mysql</groupId>
  155 + <artifactId>mysql-connector-j</artifactId>
  156 + <version>8.4.0</version>
  157 + <scope>compile</scope>
182 </dependency> 158 </dependency>
183 <!-- oracle--> 159 <!-- oracle-->
184 <!--<dependency>--> 160 <!--<dependency>-->
@@ -190,7 +166,7 @@ @@ -190,7 +166,7 @@
190 <dependency> 166 <dependency>
191 <groupId>com.github.pagehelper</groupId> 167 <groupId>com.github.pagehelper</groupId>
192 <artifactId>pagehelper-spring-boot-starter</artifactId> 168 <artifactId>pagehelper-spring-boot-starter</artifactId>
193 - <version>1.2.5</version> 169 + <version>1.4.7</version>
194 </dependency> 170 </dependency>
195 <!-- https://mvnrepository.com/artifact/org.dom4j/dom4j --> 171 <!-- https://mvnrepository.com/artifact/org.dom4j/dom4j -->
196 <dependency> 172 <dependency>
@@ -212,11 +188,11 @@ @@ -212,11 +188,11 @@
212 <!-- <artifactId>spring-cloud-starter-zipkin</artifactId>--> 188 <!-- <artifactId>spring-cloud-starter-zipkin</artifactId>-->
213 <!-- </dependency>--> 189 <!-- </dependency>-->
214 190
215 - <dependency>  
216 - <groupId>de.codecentric</groupId>  
217 - <artifactId>spring-boot-admin-starter-client</artifactId>  
218 - <version>2.1.6</version>  
219 - </dependency> 191 +<!-- <dependency>-->
  192 +<!-- <groupId>de.codecentric</groupId>-->
  193 +<!-- <artifactId>spring-boot-admin-starter-client</artifactId>-->
  194 +<!-- <version>2.1.6</version>-->
  195 +<!-- </dependency>-->
220 <dependency> 196 <dependency>
221 <groupId>org.springframework.boot</groupId> 197 <groupId>org.springframework.boot</groupId>
222 <artifactId>spring-boot-starter-actuator</artifactId> 198 <artifactId>spring-boot-starter-actuator</artifactId>
@@ -245,7 +221,7 @@ @@ -245,7 +221,7 @@
245 <dependency> 221 <dependency>
246 <groupId>cn.hutool</groupId> 222 <groupId>cn.hutool</groupId>
247 <artifactId>hutool-all</artifactId> 223 <artifactId>hutool-all</artifactId>
248 - <version>5.7.14</version> 224 + <version>5.8.39</version>
249 </dependency> 225 </dependency>
250 </dependencies> 226 </dependencies>
251 227
@@ -289,9 +265,9 @@ @@ -289,9 +265,9 @@
289 <id>gen-webadmin</id> 265 <id>gen-webadmin</id>
290 <phase>package</phase> 266 <phase>package</phase>
291 <configuration> 267 <configuration>
292 - <tasks> 268 + <target>
293 <copy todir="docker" file="target/${project.artifactId}-${project.version}.${project.packaging}" /> 269 <copy todir="docker" file="target/${project.artifactId}-${project.version}.${project.packaging}" />
294 - </tasks> 270 + </target>
295 </configuration> 271 </configuration>
296 <goals> 272 <goals>
297 <goal>run</goal> 273 <goal>run</goal>
1 -package com.tianbo.warehouse;  
2 -  
3 -import org.springframework.context.annotation.Bean;  
4 -import org.springframework.context.annotation.Configuration;  
5 -import springfox.documentation.builders.ApiInfoBuilder;  
6 -import springfox.documentation.builders.PathSelectors;  
7 -import springfox.documentation.builders.RequestHandlerSelectors;  
8 -import springfox.documentation.service.ApiInfo;  
9 -import springfox.documentation.service.Contact;  
10 -import springfox.documentation.spi.DocumentationType;  
11 -import springfox.documentation.spring.web.plugins.Docket;  
12 -import springfox.documentation.swagger2.annotations.EnableSwagger2;  
13 -  
14 -@Configuration  
15 -@EnableSwagger2  
16 -public class Swagger2 {  
17 - //swagger2的配置文件,这里可以配置swagger2的一些基本的内容,比如扫描的包等等  
18 - @Bean  
19 - public Docket createRestApi() {  
20 - return new Docket(DocumentationType.SWAGGER_2)  
21 - .apiInfo(apiInfo())  
22 - .select()  
23 - //为当前包路径  
24 - .apis(RequestHandlerSelectors.basePackage("com.tianbo.warehouse.controller"))  
25 - .paths(PathSelectors.any())  
26 - .build();  
27 - }  
28 - //构建 api文档的详细信息函数,注意这里的注解引用的是哪个  
29 - private ApiInfo apiInfo() {  
30 - return new ApiInfoBuilder()  
31 - //页面标题  
32 - .title("Spring Boot 测试使用 Swagger2 构建RESTful API")  
33 - //创建人  
34 - .contact(new Contact("MarryFeng", "http://www.baidu.com", ""))  
35 - //版本号  
36 - .version("1.0")  
37 - //描述  
38 - .description("API 描述")  
39 - .build();  
40 - }  
41 -  
42 -  
43 -}  
1 package com.tianbo.warehouse.annotation; 1 package com.tianbo.warehouse.annotation;
2 2
3 -import com.alibaba.fastjson.JSON; 3 +import com.alibaba.fastjson2.JSON;
4 import com.tianbo.warehouse.model.LOGWithBLOBs; 4 import com.tianbo.warehouse.model.LOGWithBLOBs;
5 import com.tianbo.warehouse.service.LogService; 5 import com.tianbo.warehouse.service.LogService;
6 import com.tianbo.warehouse.util.IO.StreamUtil; 6 import com.tianbo.warehouse.util.IO.StreamUtil;
1 package com.tianbo.warehouse.annotation.cache.util.redis; 1 package com.tianbo.warehouse.annotation.cache.util.redis;
2 2
3 -import com.alibaba.druid.util.StringUtils; 3 +import org.apache.commons.lang3.StringUtils;
4 import lombok.extern.slf4j.Slf4j; 4 import lombok.extern.slf4j.Slf4j;
5 5
6 import org.aspectj.lang.ProceedingJoinPoint; 6 import org.aspectj.lang.ProceedingJoinPoint;
1 -package com.tianbo.warehouse.bean;  
2 -  
3 -import org.springframework.context.annotation.Bean;  
4 -import org.springframework.context.annotation.Configuration;  
5 -import org.springframework.web.socket.server.standard.ServerEndpointExporter;  
6 -  
7 -@Configuration  
8 -public class WebSocketConfig {  
9 - @Bean  
10 - public ServerEndpointExporter serverEndpointExporter() {  
11 - return new ServerEndpointExporter();  
12 - }  
13 -}  
1 package com.tianbo.warehouse.controller; 1 package com.tianbo.warehouse.controller;
2 2
3 -import com.alibaba.fastjson.JSON; 3 +import com.alibaba.fastjson2.JSON;
4 4
5 -import com.alibaba.fastjson.JSONException;  
6 -import com.alibaba.fastjson.JSONObject; 5 +import com.alibaba.fastjson2.JSONException;
  6 +import com.alibaba.fastjson2.JSONObject;
7 import com.google.code.kaptcha.impl.DefaultKaptcha; 7 import com.google.code.kaptcha.impl.DefaultKaptcha;
8 8
9 import com.thoughtworks.xstream.core.util.Base64Encoder; 9 import com.thoughtworks.xstream.core.util.Base64Encoder;
1 package com.tianbo.warehouse.controller; 1 package com.tianbo.warehouse.controller;
2 2
3 -import com.alibaba.fastjson.JSON;  
4 -import com.alibaba.fastjson.JSONObject; 3 +import com.alibaba.fastjson2.JSON;
  4 +import com.alibaba.fastjson2.JSONObject;
5 import com.tianbo.warehouse.controller.response.ResultJson; 5 import com.tianbo.warehouse.controller.response.ResultJson;
6 import com.tianbo.warehouse.dao.USERSMapper; 6 import com.tianbo.warehouse.dao.USERSMapper;
7 import com.tianbo.warehouse.model.Token; 7 import com.tianbo.warehouse.model.Token;
1 package com.tianbo.warehouse.controller; 1 package com.tianbo.warehouse.controller;
2 2
3 -import com.alibaba.fastjson.JSON; 3 +import com.alibaba.fastjson2.JSON;
4 import com.github.pagehelper.PageInfo; 4 import com.github.pagehelper.PageInfo;
5 import com.tianbo.warehouse.annotation.LogAnnotation; 5 import com.tianbo.warehouse.annotation.LogAnnotation;
6 import com.tianbo.warehouse.annotation.RequestRequire; 6 import com.tianbo.warehouse.annotation.RequestRequire;
@@ -21,7 +21,6 @@ import io.swagger.annotations.ApiOperation; @@ -21,7 +21,6 @@ import io.swagger.annotations.ApiOperation;
21 import lombok.extern.slf4j.Slf4j; 21 import lombok.extern.slf4j.Slf4j;
22 import org.apache.commons.lang.StringUtils; 22 import org.apache.commons.lang.StringUtils;
23 import org.springframework.beans.factory.annotation.Autowired; 23 import org.springframework.beans.factory.annotation.Autowired;
24 -import org.springframework.messaging.handler.annotation.Header;  
25 import org.springframework.security.core.context.SecurityContextHolder; 24 import org.springframework.security.core.context.SecurityContextHolder;
26 import org.springframework.security.core.userdetails.UserDetails; 25 import org.springframework.security.core.userdetails.UserDetails;
27 import org.springframework.validation.BindingResult; 26 import org.springframework.validation.BindingResult;
1 package com.tianbo.warehouse.controller.response; 1 package com.tianbo.warehouse.controller.response;
2 2
3 -import com.alibaba.fastjson.JSON; 3 +import com.alibaba.fastjson2.JSON;
4 import org.springframework.core.MethodParameter; 4 import org.springframework.core.MethodParameter;
5 import org.springframework.http.MediaType; 5 import org.springframework.http.MediaType;
6 import org.springframework.http.converter.HttpMessageConverter; 6 import org.springframework.http.converter.HttpMessageConverter;
1 package com.tianbo.warehouse.model; 1 package com.tianbo.warehouse.model;
2 2
3 -import com.alibaba.fastjson.annotation.JSONField;  
4 -import com.alibaba.fastjson.serializer.SerializerFeature; 3 +import com.alibaba.fastjson2.annotation.JSONField;
  4 +import com.alibaba.fastjson2.JSONWriter;
  5 +
5 import com.tianbo.warehouse.service.validated.InsertUser; 6 import com.tianbo.warehouse.service.validated.InsertUser;
6 import com.tianbo.warehouse.service.validated.UpdateUser; 7 import com.tianbo.warehouse.service.validated.UpdateUser;
7 import com.tianbo.warehouse.validate.CheckUserExist; 8 import com.tianbo.warehouse.validate.CheckUserExist;
8 -import org.hibernate.validator.constraints.Length; 9 +
9 import org.springframework.security.core.GrantedAuthority; 10 import org.springframework.security.core.GrantedAuthority;
10 import org.springframework.security.core.authority.SimpleGrantedAuthority; 11 import org.springframework.security.core.authority.SimpleGrantedAuthority;
11 import org.springframework.security.core.userdetails.UserDetails; 12 import org.springframework.security.core.userdetails.UserDetails;
12 13
13 -import javax.validation.constraints.*;  
14 import java.util.ArrayList; 14 import java.util.ArrayList;
15 import java.util.Collection; 15 import java.util.Collection;
16 import java.util.Date; 16 import java.util.Date;
17 import java.util.List; 17 import java.util.List;
  18 +import javax.validation.constraints.DecimalMin;
  19 +import javax.validation.constraints.NotBlank;
  20 +import javax.validation.constraints.NotNull;
  21 +import javax.validation.constraints.Size;
  22 +
18 23
19 public class USERS implements UserDetails { 24 public class USERS implements UserDetails {
20 25
@@ -24,13 +29,13 @@ public class USERS implements UserDetails { @@ -24,13 +29,13 @@ public class USERS implements UserDetails {
24 private Integer userId; 29 private Integer userId;
25 30
26 @NotBlank(message="用户名不能为空",groups={InsertUser.class, UpdateUser.class}) 31 @NotBlank(message="用户名不能为空",groups={InsertUser.class, UpdateUser.class})
27 - @Length(min = 1, max = 18, message = "username 长度必须在 {min} - {max} 之间",groups={InsertUser.class, UpdateUser.class}) 32 + @Size(min = 1, max = 18, message = "username 长度必须在 {min} - {max} 之间",groups={InsertUser.class, UpdateUser.class})
28 @CheckUserExist(message = "用户已存在",groups=InsertUser.class) 33 @CheckUserExist(message = "用户已存在",groups=InsertUser.class)
29 private String username; 34 private String username;
30 35
31 @NotNull(message="密码不能为null",groups=InsertUser.class) 36 @NotNull(message="密码不能为null",groups=InsertUser.class)
32 @NotBlank(message="密码不能为空",groups=InsertUser.class) 37 @NotBlank(message="密码不能为空",groups=InsertUser.class)
33 - @Length(min = 6, max = 22, message = "密码 长度必须在 {min} - {max} 之间",groups=InsertUser.class) 38 + @Size(min = 6, max = 22, message = "密码 长度必须在 {min} - {max} 之间",groups=InsertUser.class)
34 private String password; 39 private String password;
35 40
36 private Date birthday; 41 private Date birthday;
@@ -72,13 +77,13 @@ public class USERS implements UserDetails { @@ -72,13 +77,13 @@ public class USERS implements UserDetails {
72 77
73 private ROLE companyInfo; 78 private ROLE companyInfo;
74 79
75 - @JSONField(serialzeFeatures= {SerializerFeature.WriteMapNullValue,SerializerFeature.WriteNullStringAsEmpty}) 80 + @JSONField(serializeFeatures= {JSONWriter.Feature.WriteNulls, JSONWriter.Feature.WriteNullStringAsEmpty})
76 private List<ROLE> roles; 81 private List<ROLE> roles;
77 82
78 - @JSONField(serialzeFeatures= {SerializerFeature.WriteMapNullValue,SerializerFeature.WriteNullStringAsEmpty}) 83 + @JSONField(serializeFeatures= {JSONWriter.Feature.WriteNulls, JSONWriter.Feature.WriteNullStringAsEmpty})
79 private List<PERMISSION> permissions; 84 private List<PERMISSION> permissions;
80 85
81 - @JSONField(serialzeFeatures= {SerializerFeature.WriteMapNullValue,SerializerFeature.WriteNullStringAsEmpty}) 86 + @JSONField(serializeFeatures= {JSONWriter.Feature.WriteNulls, JSONWriter.Feature.WriteNullStringAsEmpty})
82 private List<DataPermission> dataPermissions; 87 private List<DataPermission> dataPermissions;
83 88
84 public Integer getUserId() { 89 public Integer getUserId() {
@@ -12,7 +12,7 @@ public class CorsConfig implements WebMvcConfigurer{ @@ -12,7 +12,7 @@ public class CorsConfig implements WebMvcConfigurer{
12 @Override 12 @Override
13 public void addCorsMappings(CorsRegistry registry) { 13 public void addCorsMappings(CorsRegistry registry) {
14 registry.addMapping("/**")//设置允许跨域的路径 14 registry.addMapping("/**")//设置允许跨域的路径
15 - .allowedOrigins("*")//设置允许跨域请求的域名 15 + .allowedOriginPatterns("*")//设置允许跨域请求的域名
16 .allowCredentials(true)//是否允许证书 不再默认开启 16 .allowCredentials(true)//是否允许证书 不再默认开启
17 .allowedMethods("GET", "POST", "PUT", "DELETE")//设置允许的方法 17 .allowedMethods("GET", "POST", "PUT", "DELETE")//设置允许的方法
18 .maxAge(3600);//跨域允许时间 18 .maxAge(3600);//跨域允许时间
1 package com.tianbo.warehouse.security.filter; 1 package com.tianbo.warehouse.security.filter;
2 2
3 -import com.alibaba.fastjson.JSON;  
4 -import com.alibaba.fastjson.JSONObject; 3 +import com.alibaba.fastjson2.JSON;
  4 +import com.alibaba.fastjson2.JSONObject;
5 import com.tianbo.warehouse.model.USERS; 5 import com.tianbo.warehouse.model.USERS;
6 import com.tianbo.warehouse.security.CustomUserDetailService; 6 import com.tianbo.warehouse.security.CustomUserDetailService;
7 import com.tianbo.warehouse.util.RedisUtils; 7 import com.tianbo.warehouse.util.RedisUtils;
1 package com.tianbo.warehouse.security.handel; 1 package com.tianbo.warehouse.security.handel;
2 2
3 -import com.alibaba.fastjson.JSONObject; 3 +import com.alibaba.fastjson2.JSONObject;
4 import org.springframework.security.core.AuthenticationException; 4 import org.springframework.security.core.AuthenticationException;
5 import org.springframework.security.web.AuthenticationEntryPoint; 5 import org.springframework.security.web.AuthenticationEntryPoint;
6 import org.springframework.stereotype.Component; 6 import org.springframework.stereotype.Component;
1 package com.tianbo.warehouse.security.handel; 1 package com.tianbo.warehouse.security.handel;
2 2
3 -import com.alibaba.fastjson.JSON; 3 +import com.alibaba.fastjson2.JSON;
4 import com.fasterxml.jackson.databind.ObjectMapper; 4 import com.fasterxml.jackson.databind.ObjectMapper;
5 import com.tianbo.warehouse.bean.AuthSuccessResponse; 5 import com.tianbo.warehouse.bean.AuthSuccessResponse;
6 import com.tianbo.warehouse.model.Token; 6 import com.tianbo.warehouse.model.Token;
1 package com.tianbo.warehouse.service.imp; 1 package com.tianbo.warehouse.service.imp;
2 2
3 import cn.hutool.core.util.ArrayUtil; 3 import cn.hutool.core.util.ArrayUtil;
4 -import com.alibaba.fastjson.JSONObject; 4 +import com.alibaba.fastjson2.JSONObject;
5 import com.github.pagehelper.Page; 5 import com.github.pagehelper.Page;
6 import com.github.pagehelper.PageHelper; 6 import com.github.pagehelper.PageHelper;
7 import com.github.pagehelper.PageInfo; 7 import com.github.pagehelper.PageInfo;
8 import com.tianbo.warehouse.annotation.cache.annotation.RedisCacheDelTarget; 8 import com.tianbo.warehouse.annotation.cache.annotation.RedisCacheDelTarget;
9 -import com.tianbo.warehouse.annotation.cache.annotation.RedisCacheEvict; 9 +
10 import com.tianbo.warehouse.annotation.cache.annotation.RedisCacheable; 10 import com.tianbo.warehouse.annotation.cache.annotation.RedisCacheable;
11 import com.tianbo.warehouse.dao.PERMISSIONMapper; 11 import com.tianbo.warehouse.dao.PERMISSIONMapper;
12 import com.tianbo.warehouse.model.PERMISSION; 12 import com.tianbo.warehouse.model.PERMISSION;
13 -import com.tianbo.warehouse.model.ROLE; 13 +
14 import com.tianbo.warehouse.model.USERS; 14 import com.tianbo.warehouse.model.USERS;
15 import com.tianbo.warehouse.service.PermissionService; 15 import com.tianbo.warehouse.service.PermissionService;
16 import com.tianbo.warehouse.util.RedisUtils; 16 import com.tianbo.warehouse.util.RedisUtils;
17 import lombok.extern.slf4j.Slf4j; 17 import lombok.extern.slf4j.Slf4j;
18 import org.apache.commons.lang.StringUtils; 18 import org.apache.commons.lang.StringUtils;
19 import org.springframework.beans.factory.annotation.Autowired; 19 import org.springframework.beans.factory.annotation.Autowired;
20 -import org.springframework.data.redis.core.RedisTemplate;  
21 import org.springframework.stereotype.Service; 20 import org.springframework.stereotype.Service;
22 21
  22 +
23 import javax.annotation.Resource; 23 import javax.annotation.Resource;
24 import javax.validation.constraints.NotNull; 24 import javax.validation.constraints.NotNull;
25 import java.util.*; 25 import java.util.*;
1 package com.tianbo.warehouse.service.imp; 1 package com.tianbo.warehouse.service.imp;
2 2
3 import cn.hutool.core.util.IdUtil; 3 import cn.hutool.core.util.IdUtil;
4 -import com.alibaba.fastjson.JSON; 4 +import com.alibaba.fastjson2.JSON;
5 import com.github.pagehelper.Page; 5 import com.github.pagehelper.Page;
6 import com.github.pagehelper.PageHelper; 6 import com.github.pagehelper.PageHelper;
7 import com.github.pagehelper.PageInfo; 7 import com.github.pagehelper.PageInfo;
1 package com.tianbo.warehouse.service.imp; 1 package com.tianbo.warehouse.service.imp;
2 2
3 -import com.alibaba.fastjson.JSONObject; 3 +import com.alibaba.fastjson2.JSONObject;
4 import com.github.pagehelper.Page; 4 import com.github.pagehelper.Page;
5 import com.github.pagehelper.PageHelper; 5 import com.github.pagehelper.PageHelper;
6 import com.github.pagehelper.PageInfo; 6 import com.github.pagehelper.PageInfo;
1 package com.tianbo.warehouse.util; 1 package com.tianbo.warehouse.util;
2 2
3 -import com.alibaba.fastjson.JSON;  
4 -import com.alibaba.fastjson.JSONArray;  
5 -import com.alibaba.fastjson.JSONObject; 3 +import com.alibaba.fastjson2.JSON;
  4 +import com.alibaba.fastjson2.JSONArray;
  5 +import com.alibaba.fastjson2.JSONObject;
6 6
7 import java.util.List; 7 import java.util.List;
8 import java.util.Map; 8 import java.util.Map;
1 package com.tianbo.warehouse.util; 1 package com.tianbo.warehouse.util;
2 import org.springframework.beans.factory.annotation.Autowired; 2 import org.springframework.beans.factory.annotation.Autowired;
3 -import org.springframework.boot.actuate.health.CompositeHealthIndicator;  
4 import org.springframework.data.redis.core.*; 3 import org.springframework.data.redis.core.*;
5 import org.springframework.stereotype.Component; 4 import org.springframework.stereotype.Component;
6 import org.springframework.util.CollectionUtils; 5 import org.springframework.util.CollectionUtils;
@@ -85,7 +84,7 @@ public class RedisUtils { @@ -85,7 +84,7 @@ public class RedisUtils {
85 if(key.length==1){ 84 if(key.length==1){
86 redisTemplate.delete(key[0]); 85 redisTemplate.delete(key[0]);
87 }else{ 86 }else{
88 - redisTemplate.delete(CollectionUtils.arrayToList(key)); 87 + redisTemplate.delete(Arrays.asList(key));
89 } 88 }
90 } 89 }
91 } 90 }
@@ -99,7 +98,7 @@ public class RedisUtils { @@ -99,7 +98,7 @@ public class RedisUtils {
99 public static Set<String> deleteBatchByKeys(String key) { 98 public static Set<String> deleteBatchByKeys(String key) {
100 Set<String> keys = new HashSet<>(); 99 Set<String> keys = new HashSet<>();
101 redisUtils.redisTemplate.execute((RedisCallback<Set<String>>) connection -> { 100 redisUtils.redisTemplate.execute((RedisCallback<Set<String>>) connection -> {
102 - try (Cursor<byte[]> cursor = connection.scan(new ScanOptions.ScanOptionsBuilder() 101 + try (Cursor<byte[]> cursor = connection.scan(ScanOptions.scanOptions()
103 .match(key + "*") 102 .match(key + "*")
104 .count(5000).build())) { 103 .count(5000).build())) {
105 while (cursor.hasNext()) { 104 while (cursor.hasNext()) {
@@ -19,7 +19,7 @@ @@ -19,7 +19,7 @@
19 <nav class="navbar navbar-inverse navbar-fixed-top"> 19 <nav class="navbar navbar-inverse navbar-fixed-top">
20 <div class="container"> 20 <div class="container">
21 <div class="navbar-header"> 21 <div class="navbar-header">
22 - <a class="navbar-brand" href="#">Spring Security演示</a> 22 + <a class="navbar-brand" href="#">用户认证中心</a>
23 </div> 23 </div>
24 <div id="navbar" class="collapse navbar-collapse"> 24 <div id="navbar" class="collapse navbar-collapse">
25 <ul class="nav navbar-nav"> 25 <ul class="nav navbar-nav">
@@ -19,7 +19,7 @@ @@ -19,7 +19,7 @@
19 <nav class="navbar navbar-inverse navbar-fixed-top"> 19 <nav class="navbar navbar-inverse navbar-fixed-top">
20 <div class="container"> 20 <div class="container">
21 <div class="navbar-header"> 21 <div class="navbar-header">
22 - <a class="navbar-brand" href="#">Spring Security演示</a> 22 + <a class="navbar-brand" href="#">用户认证中心</a>
23 </div> 23 </div>
24 <div id="navbar" class="collapse navbar-collapse"> 24 <div id="navbar" class="collapse navbar-collapse">
25 <ul class="nav navbar-nav"> 25 <ul class="nav navbar-nav">
@@ -19,7 +19,7 @@ @@ -19,7 +19,7 @@
19 <nav class="navbar navbar-inverse navbar-fixed-top"> 19 <nav class="navbar navbar-inverse navbar-fixed-top">
20 <div class="container"> 20 <div class="container">
21 <div class="navbar-header"> 21 <div class="navbar-header">
22 - <a class="navbar-brand" href="#">Spring Security演示</a> 22 + <a class="navbar-brand" href="#">用户认证中心</a>
23 </div> 23 </div>
24 <div id="navbar" class="collapse navbar-collapse"> 24 <div id="navbar" class="collapse navbar-collapse">
25 <ul class="nav navbar-nav"> 25 <ul class="nav navbar-nav">
@@ -19,7 +19,7 @@ @@ -19,7 +19,7 @@
19 <nav class="navbar navbar-inverse navbar-fixed-top"> 19 <nav class="navbar navbar-inverse navbar-fixed-top">
20 <div class="container"> 20 <div class="container">
21 <div class="navbar-header"> 21 <div class="navbar-header">
22 - <a class="navbar-brand" href="#">Spring Security演示</a> 22 + <a class="navbar-brand" href="#">用户认证中心</a>
23 </div> 23 </div>
24 <div id="navbar" class="collapse navbar-collapse"> 24 <div id="navbar" class="collapse navbar-collapse">
25 <ul class="nav navbar-nav"> 25 <ul class="nav navbar-nav">