Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encrypt the password #391

Merged
merged 6 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ jobs:
uses: actions/checkout@v2
with:
submodules: recursive
-
-
name: Setup Node
uses: actions/setup-node@v2.4.0
with:
node-version: "16"
-
node-version: "18"
-
name: Setup Dependencies
run: yarn install
-
-
name: Build Site
run: npm run build
-
-
name: Deploy
uses: peaceiris/actions-gh-pages@v3
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
Expand All @@ -37,4 +37,4 @@ jobs:
user_email: 'github-actions[bot]@users.noreply.github.com'
publish_branch: dist
publish_dir: ./dist

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"@babel/polyfill": "^7.0.0-beta.36",
"antd": "^3.26.19",
"classnames": "^2.2.5",
"crypto-js": "^4.2.0",
"dayjs": "^1.8.17",
"dva": "^2.2.3",
"dva-loading": "^2.0.3",
Expand Down
40 changes: 37 additions & 3 deletions src/routes/User/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,36 @@
* limitations under the License.
*/

import React, { Component } from 'react';
import { connect } from 'dva';
import { Alert } from 'antd';
import React, {Component} from 'react';
import CryptoJS from 'crypto-js';
import {connect} from 'dva';
import {Alert} from 'antd';
import Login from 'components/Login';
import styles from './Login.less';
import {querySecretInfo} from "../../services/api";

const { UserName, Password, Submit, VerifyCode, LoginCode } = Login;

let secretKey= ""
let secretIv = ""
async function initSecret() {
try {
let promise = await querySecretInfo();
if (typeof promise !== 'undefined') {
if (promise.status === 200) {
let body = await promise.json();
let secret = JSON.parse(atob(body.data));
if ((secret.key != null && secret.key !== "") && (secret.iv != null && secret.iv !== "")) {
secretKey = secret.key
secretIv = secret.iv;
}
}
}
} catch (e) {
// ignore error
}
}
initSecret().then(() => {});
@connect(({ login, loading }) => ({
login,
submitting: loading.effects['login/login'],
Expand Down Expand Up @@ -49,6 +72,17 @@ export default class LoginPage extends Component {
this.ChildRef.current.handleChange();
return;
}
if (secretKey !== "" && secretIv !== "" ){
const keyByte = CryptoJS.enc.Utf8.parse(secretKey);
const ivByte = CryptoJS.enc.Utf8.parse(secretIv);
const encryptedPassword = CryptoJS.AES.encrypt(values.password, keyByte, {
iv: ivByte,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7
});
values.password = encryptedPassword.toString();
}

dispatch({
type: 'login/login',
payload: {
Expand Down
6 changes: 6 additions & 0 deletions src/services/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,12 @@ export async function queryLogin(params) {
});
}

export async function querySecretInfo() {
return fetch(`${baseUrl}/platform/secretInfo`)
.catch(() => {
});
}

// sync all plugin
export async function asyncPlugin() {
return request(`${baseUrl}/plugin/syncPluginAll`, {
Expand Down
Loading