fix(auth): stop storing recoverable passwords
This commit is contained in:
1 parent
770d1e1547
commit
0d2165cf80
4 files changed
+2
-44
No files matched your search
@@ -49,7 +49,6 @@
|
||||
"element-plus": "2.6.1",
|
||||
"fast-xml-parser": "^4.3.2",
|
||||
"highlight.js": "^11.9.0",
|
||||
"jsencrypt": "^3.3.2",
|
||||
"lodash-es": "^4.17.21",
|
||||
"min-dash": "^4.1.1",
|
||||
"mitt": "^3.0.1",
|
||||
|
||||
Generated
-8
@@ -80,9 +80,6 @@ importers:
|
||||
highlight.js:
|
||||
specifier: ^11.9.0
|
||||
version: 11.11.1
|
||||
jsencrypt:
|
||||
specifier: ^3.3.2
|
||||
version: 3.5.4
|
||||
lodash-es:
|
||||
specifier: ^4.17.21
|
||||
version: 4.18.1
|
||||
@@ -3809,9 +3806,6 @@ packages:
|
||||
resolution: {integrity: sha512-1td788aAnnZ5qs7V2QIRl1owjtYpbKt749Y3xauqQgwIIGF/xXWz1wMTEBx5O3LK3lXLVuqXPdPxj2BoFHaW9Q==}
|
||||
hasBin: true
|
||||
|
||||
jsencrypt@3.5.4:
|
||||
resolution: {integrity: sha512-kNjfYEMNASxrDGsmcSQh/rUTmcoRfSUkxnAz+MMywM8jtGu+fFEZ3nJjHM58zscVnwR0fYmG9sGkTDjqUdpiwA==}
|
||||
|
||||
jsesc@3.1.0:
|
||||
resolution: {integrity: sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA==}
|
||||
engines: {node: '>=6'}
|
||||
@@ -9545,8 +9539,6 @@ snapshots:
|
||||
dependencies:
|
||||
argparse: 2.0.1
|
||||
|
||||
jsencrypt@3.5.4: {}
|
||||
|
||||
jsesc@3.1.0: {}
|
||||
|
||||
json-buffer@3.0.1: {}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { useCache, CACHE_KEY } from '@/hooks/web/useCache'
|
||||
import { TokenType } from '@/api/login/types'
|
||||
import { decrypt, encrypt } from '@/utils/jsencrypt'
|
||||
|
||||
const { wsCache } = useCache()
|
||||
|
||||
@@ -46,14 +45,13 @@ export type LoginFormType = {
|
||||
export const getLoginForm = () => {
|
||||
const loginForm: LoginFormType = wsCache.get(CACHE_KEY.LoginForm)
|
||||
if (loginForm) {
|
||||
loginForm.password = decrypt(loginForm.password) as string
|
||||
loginForm.password = ''
|
||||
}
|
||||
return loginForm
|
||||
}
|
||||
|
||||
export const setLoginForm = (loginForm: LoginFormType) => {
|
||||
loginForm.password = encrypt(loginForm.password) as string
|
||||
wsCache.set(CACHE_KEY.LoginForm, loginForm, { exp: 30 * 24 * 60 * 60 })
|
||||
wsCache.set(CACHE_KEY.LoginForm, { ...loginForm, password: '' }, { exp: 30 * 24 * 60 * 60 })
|
||||
}
|
||||
|
||||
export const removeLoginForm = () => {
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
import { JSEncrypt } from 'jsencrypt'
|
||||
|
||||
// 密钥对生成 http://web.chacuo.net/netrsakeypair
|
||||
|
||||
const publicKey =
|
||||
'MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKoR8mX0rGKLqzcWmOzbfj64K8ZIgOdH\n' +
|
||||
'nzkXSOVOZbFu/TJhZ7rFAN+eaGkl3C4buccQd/EjEsj9ir7ijT7h96MCAwEAAQ=='
|
||||
|
||||
const privateKey =
|
||||
'MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAqhHyZfSsYourNxaY\n' +
|
||||
'7Nt+PrgrxkiA50efORdI5U5lsW79MmFnusUA355oaSXcLhu5xxB38SMSyP2KvuKN\n' +
|
||||
'PuH3owIDAQABAkAfoiLyL+Z4lf4Myxk6xUDgLaWGximj20CUf+5BKKnlrK+Ed8gA\n' +
|
||||
'kM0HqoTt2UZwA5E2MzS4EI2gjfQhz5X28uqxAiEA3wNFxfrCZlSZHb0gn2zDpWow\n' +
|
||||
'cSxQAgiCstxGUoOqlW8CIQDDOerGKH5OmCJ4Z21v+F25WaHYPxCFMvwxpcw99Ecv\n' +
|
||||
'DQIgIdhDTIqD2jfYjPTY8Jj3EDGPbH2HHuffvflECt3Ek60CIQCFRlCkHpi7hthh\n' +
|
||||
'YhovyloRYsM+IS9h/0BzlEAuO0ktMQIgSPT3aFAgJYwKpqRYKlLDVcflZFCKY7u3\n' +
|
||||
'UP8iWi1Qw0Y='
|
||||
|
||||
// 加密
|
||||
export const encrypt = (txt: string) => {
|
||||
const encryptor = new JSEncrypt()
|
||||
encryptor.setPublicKey(publicKey) // 设置公钥
|
||||
return encryptor.encrypt(txt) // 对数据进行加密
|
||||
}
|
||||
|
||||
// 解密
|
||||
export const decrypt = (txt: string) => {
|
||||
const encryptor = new JSEncrypt()
|
||||
encryptor.setPrivateKey(privateKey) // 设置私钥
|
||||
return encryptor.decrypt(txt) // 对数据进行解密
|
||||
}
|
||||
Reference in new issue
Block a user