# v2.9.0 升级至 v2.10.0
# 组件更改说明
该升级指南以v2.9.0版本为基准,更早的版本请先参考之前版本的升级文档。
diboot v2.10.x 是基于 spring boot 2.7.x 的长期维护版本。
将diboot所有的组件版本号替换至2.10.0的最新版本,然后按照下述内容进行相关更改即可。
# PC端登录的密码传输加密
# 后端部分:
- 参考playground项目下的 application.properties (opens new window) 配置RSA密钥
rsa-encryptor.private-key=.....
1
- AuthTokenController中修改登录接口 (或者通过devtools重新生成该初始文件)
// 注入私钥
@Value("${r'${rsa-encryptor.private-key}'}")
private String rsaPrivateKey;
// 修改登录接口,解密传输过来的密码
@PostMapping("/auth/login")
public JsonResult login(@RequestBody PwdCredential credential) throws Exception{
// 获取缓存中的验证码
String traceId = credential.getTraceId();
String verCode = credential.getCaptcha();
String captcha = baseCacheManager.getCacheString(Cons.CACHE_CAPTCHA, traceId);
baseCacheManager.removeCacheObj(Cons.CACHE_CAPTCHA, traceId);
// 判断验证码
if (verCode == null || !verCode.trim().toLowerCase().equals(captcha)) {
return JsonResult.FAIL_VALIDATION("验证码错误");
}
credential.setPassword(decrypt(credential.getPassword()));
return JsonResult.OK(AuthServiceFactory.getAuthService(Cons.DICTCODE_AUTH_TYPE.PWD.name()).applyToken(credential));
}
/**
* RSA 解密
*
* @param content
* @return
*/
private String decrypt(String content) {
try {
byte[] decode = Base64.getDecoder().decode(content);
// base64编码的私钥
byte[] decoded = Base64.getDecoder().decode(rsaPrivateKey);
RSAPrivateKey priKey = (RSAPrivateKey) KeyFactory.getInstance("RSA")
.generatePrivate(new PKCS8EncodedKeySpec(decoded));
// RSA解密
Cipher cipher = Cipher.getInstance("RSA");
cipher.init(Cipher.DECRYPT_MODE, priKey);
return new String(cipher.doFinal(decode));
} catch (Exception e) {
throw new BusinessException(Status.FAIL_OPERATION, "解密数据失败!");
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# 前端登录页:
打开前端 Login.vue 文件,找到 encryptor.setPublicKey 修改公钥值:
const encryptor = new JSEncrypt()
encryptor.setPublicKey(`.....`)
1
2
2
# 前端升级说明
- diboot-antd-admin前端调整
升级前请下载diboot-antd-admin 2.10.0 (opens new window)源码包,以下升级流程将依赖此包。
- diboot-element-admin前端调整
升级前请下载diboot-element-admin 2.10.0 (opens new window)源码包,以下升级流程将依赖此包。
- diboot-mobile-ui前端调整
升级前请下载diboot-mobile-ui 2.10.0 (opens new window)源码包,以下升级流程将依赖此包。
- 对比新旧版本的相关页面及代码,替换或合并至本地。
← 常见问题FAQ 2.8.0升至2.9.0 →