yuang-framework-ui-common 1.0.11 → 1.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/utils/aesUtils.ts +4 -6
- package/lib/utils/ssoUtils.ts +15 -1
- package/package.json +1 -1
- package/src/.DS_Store +0 -0
package/lib/utils/aesUtils.ts
CHANGED
@@ -30,14 +30,12 @@ const aesDecrypt = (aesKey, originData) => {
|
|
30
30
|
* 生成16位随机码
|
31
31
|
* @returns {string}
|
32
32
|
*/
|
33
|
-
const
|
34
|
-
var chars = [ '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K', 'L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f',
|
35
|
-
'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'
|
36
|
-
]
|
33
|
+
const getAesRandomKey = () => {
|
34
|
+
var chars = [ '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K', 'L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f', 'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'];
|
37
35
|
var nums = ''
|
38
36
|
// 这个地方切记要选择16位,因为美国对密钥长度有限制,选择32位的话加解密会报错,需要根据jdk版本去修改相关jar包,有点恼火,选择16位就不用处理。
|
39
37
|
for (var i = 0; i < 16; i++) {
|
40
|
-
|
38
|
+
let id = parseInt((Math.random() * 61).toString());
|
41
39
|
nums += chars[id]
|
42
40
|
}
|
43
41
|
return nums
|
@@ -46,5 +44,5 @@ const getAesKey = () => {
|
|
46
44
|
export {
|
47
45
|
aesEncrypt,
|
48
46
|
aesDecrypt,
|
49
|
-
|
47
|
+
getAesRandomKey
|
50
48
|
}
|
package/lib/utils/ssoUtils.ts
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
'use strict'
|
2
2
|
|
3
|
-
|
4
3
|
import Cookies from 'js-cookie'
|
4
|
+
import {getAesRandomKey, aesEncrypt} from './aesUtils';
|
5
|
+
import {rsaEncrypt} from './rsaUtils';
|
6
|
+
|
5
7
|
|
6
8
|
const getSsoLoginUrl = (redirectUrl = '') => {
|
7
9
|
let ssoLoginUrl = ((window as any).$config?.apiFullBaseUrl ?? '') + '/sso-api/server/sso/login';
|
@@ -37,6 +39,18 @@ const getSsoLoginRoutePath = (redirectRoutePath = '') => {
|
|
37
39
|
return ssoLoginRoutePath;
|
38
40
|
}
|
39
41
|
|
42
|
+
const getSsoEncrypt = (password = '') => {
|
43
|
+
let gatewayPublicKey = localStorage.getItem('gatewayPublicKey');
|
44
|
+
// 每次请求生成aeskey
|
45
|
+
let aesKey = getAesRandomKey();
|
46
|
+
// 用登陆后后端生成并返回给前端的的RSA密钥对的公钥将AES16位密钥进行加密
|
47
|
+
const rsaAesKey = rsaEncrypt(aesKey, gatewayPublicKey);
|
48
|
+
// 使用AES16位的密钥将请求报文加密(使用的是加密前的aes密钥)
|
49
|
+
const encryptPassword = aesEncrypt(aesKey, password);
|
50
|
+
|
51
|
+
return {encryptPassword, rsaAesKey};
|
52
|
+
}
|
53
|
+
|
40
54
|
|
41
55
|
const ssoAccessTokenCookieKey: string = 'Sso-Access-Token';
|
42
56
|
const ssoAccessTokenLocalKey: string = 'ssoAccessToken';
|
package/package.json
CHANGED
package/src/.DS_Store
DELETED
Binary file
|