You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shenyu.apache.org by he...@apache.org on 2024/03/05 09:07:39 UTC
(shenyu-dashboard) branch master updated: Encrypt the password (#391)
This is an automated email from the ASF dual-hosted git repository.
hefengen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shenyu-dashboard.git
The following commit(s) were added to refs/heads/master by this push:
new a88833ce Encrypt the password (#391)
a88833ce is described below
commit a88833cea0b1b8d0fd8d33eaf11863029441b052
Author: wlngo <85...@users.noreply.github.com>
AuthorDate: Tue Mar 5 17:07:33 2024 +0800
Encrypt the password (#391)
* AES/CBC/PKCS5Padding encrypt shenyu-admin login password
* Modified to AES/CTR/NoPadding mode
* update ci build_and_deploy_job node-version to 18
* Update key acquisition method
* Update key acquisition method
* Modified to AES/CBC/Pkcs7Padding
---
.github/workflows/deploy.yml | 12 ++++++------
package.json | 1 +
src/routes/User/Login.js | 40 +++++++++++++++++++++++++++++++++++++---
src/services/api.js | 6 ++++++
4 files changed, 50 insertions(+), 9 deletions(-)
diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml
index 8a7130ab..99020071 100644
--- a/.github/workflows/deploy.yml
+++ b/.github/workflows/deploy.yml
@@ -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'
@@ -37,4 +37,4 @@ jobs:
user_email: 'github-actions[bot]@users.noreply.github.com'
publish_branch: dist
publish_dir: ./dist
-
+
diff --git a/package.json b/package.json
index a1598e99..7696d008 100755
--- a/package.json
+++ b/package.json
@@ -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",
diff --git a/src/routes/User/Login.js b/src/routes/User/Login.js
index e1f295aa..0fbf2279 100644
--- a/src/routes/User/Login.js
+++ b/src/routes/User/Login.js
@@ -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'],
@@ -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: {
diff --git a/src/services/api.js b/src/services/api.js
index e6b3ee36..a6d6674d 100644
--- a/src/services/api.js
+++ b/src/services/api.js
@@ -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`, {