feat: update encryption process to use UTF-8 encoding for login form data
parent
9faebd8a41
commit
92e8a9105f
|
|
@ -252,7 +252,9 @@ const loginHandle = () => {
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
const publicKey = forge.pki.publicKeyFromPem(chatUser?.chat_profile?.rasKey as any);
|
const publicKey = forge.pki.publicKeyFromPem(chatUser?.chat_profile?.rasKey as any);
|
||||||
const encrypted = publicKey.encrypt(JSON.stringify(loginForm.value), 'RSAES-PKCS1-V1_5');
|
const jsonData = JSON.stringify(loginForm.value);
|
||||||
|
const utf8Bytes = forge.util.encodeUtf8(jsonData);
|
||||||
|
const encrypted = publicKey.encrypt(utf8Bytes, 'RSAES-PKCS1-V1_5');
|
||||||
const encryptedBase64 = forge.util.encode64(encrypted);
|
const encryptedBase64 = forge.util.encode64(encrypted);
|
||||||
chatUser.login({
|
chatUser.login({
|
||||||
encryptedData: encryptedBase64,
|
encryptedData: encryptedBase64,
|
||||||
|
|
@ -438,10 +440,10 @@ onBeforeMount(() => {
|
||||||
console.log('DingTalk client request success:', res)
|
console.log('DingTalk client request success:', res)
|
||||||
chatUser.dingOauth2Callback(res.code, accessToken).then(() => {
|
chatUser.dingOauth2Callback(res.code, accessToken).then(() => {
|
||||||
router.push({
|
router.push({
|
||||||
name: 'chat',
|
name: 'chat',
|
||||||
params: {accessToken: accessToken},
|
params: {accessToken: accessToken},
|
||||||
query: route.query,
|
query: route.query,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -201,7 +201,10 @@ const loginHandle = () => {
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
const publicKey = forge.pki.publicKeyFromPem(user.rasKey);
|
const publicKey = forge.pki.publicKeyFromPem(user.rasKey);
|
||||||
const encrypted = publicKey.encrypt(JSON.stringify(loginForm.value), 'RSAES-PKCS1-V1_5');
|
// 转换为UTF-8编码后再加密
|
||||||
|
const jsonData = JSON.stringify(loginForm.value);
|
||||||
|
const utf8Bytes = forge.util.encodeUtf8(jsonData);
|
||||||
|
const encrypted = publicKey.encrypt(utf8Bytes, 'RSAES-PKCS1-V1_5');
|
||||||
const encryptedBase64 = forge.util.encode64(encrypted);
|
const encryptedBase64 = forge.util.encode64(encrypted);
|
||||||
login
|
login
|
||||||
.asyncLogin({encryptedData: encryptedBase64, username: loginForm.value.username})
|
.asyncLogin({encryptedData: encryptedBase64, username: loginForm.value.username})
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue