1
0
mirror of https://github.com/chillzhuang/Sword synced 2024-11-23 18:59:27 +08:00

🎉 4.1.0.RELEASE 登录认证升级为国密算法,数据库password字段内容无需变动

This commit is contained in:
smallchill 2024-07-14 23:41:31 +08:00
parent b9f3111b0e
commit d928cfceeb
6 changed files with 142 additions and 140 deletions

238
README.md
View File

@ -1,9 +1,9 @@
<p align="center"> <p align="center">
<img src="https://img.shields.io/badge/Release-V3.7.1-green.svg" alt="Downloads"> <img src="https://img.shields.io/badge/Release-V4.1.0-green.svg" alt="Downloads">
<img src="https://img.shields.io/badge/JDK-1.8+-green.svg" alt="Build Status"> <img src="https://img.shields.io/badge/JDK-17+-green.svg" alt="Build Status">
<img src="https://img.shields.io/badge/license-Apache%202-blue.svg" alt="Build Status"> <img src="https://img.shields.io/badge/license-Apache%202-blue.svg" alt="Build Status">
<img src="https://img.shields.io/badge/Spring%20Cloud-2021-blue.svg" alt="Coverage Status"> <img src="https://img.shields.io/badge/Spring%20Cloud-2023-blue.svg" alt="Coverage Status">
<img src="https://img.shields.io/badge/Spring%20Boot-2.7.18-blue.svg" alt="Downloads"> <img src="https://img.shields.io/badge/Spring%20Boot-3.2-blue.svg" alt="Downloads">
<a target="_blank" href="https://bladex.cn"> <a target="_blank" href="https://bladex.cn">
<img src="https://img.shields.io/badge/Author-Small%20Chill-ff69b4.svg" alt="Downloads"> <img src="https://img.shields.io/badge/Author-Small%20Chill-ff69b4.svg" alt="Downloads">
</a> </a>
@ -18,51 +18,116 @@
* [BladeTool](https://github.com/chillzhuang/blade-tool)已推送至Maven中央库直接引入即可减少了工程的臃肿也可更注重于业务开发 * [BladeTool](https://github.com/chillzhuang/blade-tool)已推送至Maven中央库直接引入即可减少了工程的臃肿也可更注重于业务开发
* 集成Sentinel从流量控制、熔断降级、系统负载等多个维度保护服务的稳定性。 * 集成Sentinel从流量控制、熔断降级、系统负载等多个维度保护服务的稳定性。
* 注册中心、配置中心选型Nacos为工程瘦身的同时加强各模块之间的联动。 * 注册中心、配置中心选型Nacos为工程瘦身的同时加强各模块之间的联动。
* 使用Traefik进行反向代理监听后台变化自动化应用新的配置文件。
* 极简封装了多租户底层用更少的代码换来拓展性更强的SaaS多租户系统。 * 极简封装了多租户底层用更少的代码换来拓展性更强的SaaS多租户系统。
* 借鉴OAuth2实现了多终端认证系统可控制子系统的token权限互相隔离。 * 借鉴OAuth2自研多终端认证系统可控制子系统的token权限互相隔离。
* 借鉴Security封装了Secure模块采用JWT做Token认证可拓展集成Redis等细颗粒度控制方案。 * 借鉴Security自研Secure模块采用JWT做Token认证可拓展集成Redis等细颗粒度控制方案。
* 稳定生产了三年,经历了从 Camden -> Hoxton -> 2021 的技术架构也经历了从fat jar -> docker -> k8s + jenkins的部署架构。 * 稳定生产了六年,经历了从 Camden -> Hoxton -> 2023 的技术架构也经历了从fat jar -> docker -> k8s + jenkins的部署架构。
* 项目分包明确,规范微服务的开发模式,使包与包之间的分工清晰。 * 项目分包明确,规范微服务的开发模式,使包与包之间的分工清晰。
## 架构图 ## 架构图
<img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/springblade-framework.png"/> <img src="https://xbladex.oss-cn-hangzhou.aliyuncs.com/upload/springblade-framework.png"/>
## 核心技术栈
| 技术栈 | 版本 |
|----------------------|------------|
| Java | 17+ |
| NodeJS | 18+ |
| Spring | 6.1.10 |
| Spring Boot | 3.2.7 |
| Spring Cloud | 2023.0.2 |
| Spring Cloud Alibaba | 2023.0.1.0 |
| Nacos Alibaba | 2.3.2 |
| Mybatis Plus | 3.5.7 |
## 工程结构
```
SpringBlade
├── blade-auth -- 授权服务提供
├── blade-common -- 常用工具封装包
├── blade-gateway -- Spring Cloud 网关
├── blade-ops -- 运维中心
├ ├── blade-admin -- spring-cloud后台管理
├ ├── blade-develop -- 代码生成
├ ├── blade-resource -- 资源管理
├ ├── blade-seata-order -- seata分布式事务demo
├ ├── blade-seata-storage -- seata分布式事务demo
├── blade-service -- 业务模块
├ ├── blade-desk -- 工作台模块
├ ├── blade-log -- 日志模块
├ ├── blade-system -- 系统模块
├ └── blade-user -- 用户模块
├── blade-service-api -- 业务模块api封装
├ ├── blade-desk-api -- 工作台api
├ ├── blade-dict-api -- 字典api
├ ├── blade-system-api -- 系统api
└── └── blade-user-api -- 用户api
```
## 官方信息 ## 官方信息
* 官网地址:[https://bladex.cn](https://bladex.cn)
* 问答社区:[https://sns.bladex.cn](https://sns.bladex.cn)
* 会员计划:[SpringBlade会员计划](https://gitee.com/smallc/SpringBlade/wikis/SpringBlade会员计划)
* 交流一群:`477853168`(满)
* 交流二群:`751253339`(满)
* 交流三群:`784729540`(满)
* 交流四群:`1034621754`(满)
* 交流五群:`946350912`(满)
* 交流六群:`511624269`(满)
* 交流七群:`298061704`
## 在线演示 | 简介 | 内容 |
* Saber-基于Vue[https://saber.bladex.cn](https://saber.bladex.cn) |------|-------------------------------------------------------------------------------|
* Sword-基于React[https://sword.bladex.cn](https://sword.bladex.cn) | 官网地址 | [https://bladex.cn](https://bladex.cn) |
| 问答社区 | [https://sns.bladex.cn](https://sns.bladex.cn) |
| 会员计划 | [SpringBlade会员计划](https://gitee.com/smallc/SpringBlade/wikis/SpringBlade会员计划) |
| 交流一群 | `477853168` (满) |
| 交流二群 | `751253339` (满) |
| 交流三群 | `784729540` (满) |
| 交流四群 | `1034621754` (满) |
| 交流五群 | `946350912` (满) |
| 交流六群 | `511624269` (满) |
| 交流七群 | `298061704` |
## 数据大屏 ## 官方产品
* 数据大屏展示系统:[https://data.bladex.cn](https://data.bladex.cn)
| 简介 | 演示地址 |
|---------------|------------------------------------------------------|
| BladeX企业级开发平台 | [https://saber3.bladex.cn](https://saber3.bladex.cn) |
| BladeX可视化数据大屏 | [https://data.bladex.cn](https://data.bladex.cn) |
| BladeX物联网开发平台 | [https://iot.bladex.cn](https://iot.bladex.cn) |
## 前端项目
| 简介 | 地址 |
|--------------------|----------------------------------------------------------------------------------------------------|
| 前端框架Sword(基于React) | [https://gitee.com/smallc/Sword](https://gitee.com/smallc/Sword) |
| 前端框架Saber(基于Vue2) | [https://gitee.com/smallc/Saber](https://gitee.com/smallc/Saber) |
| 前端框架Saber3(基于Vue3) | [https://gitee.com/smallc/Saber3](https://gitee.com/smallc/Saber/tree/3.x/) |
## 后端项目
| 简介 | 地址 |
|---------------|----------------------------------------------------------------------------------------------------|
| 核心框架项目地址 | [https://gitee.com/smallc/blade-tool](https://gitee.com/smallc/blade-tool) |
| 后端Gitee地址 | [https://gitee.com/smallc/SpringBlade](https://gitee.com/smallc/SpringBlade) |
| 后端Github地址 | [https://github.com/chillzhuang/SpringBlade](https://github.com/chillzhuang/SpringBlade) |
| 后端SpringBoot版 | [https://gitee.com/smallc/SpringBlade/tree/boot/](https://gitee.com/smallc/SpringBlade/tree/boot/) |
## 安全手册
| 简介 | 地址 |
|-----------|----------------------------------------------------------------------------------------------------|
| Blade安全手册 | [https://www.kancloud.cn/smallchill/blade-safety](https://www.kancloud.cn/smallchill/blade-safety) |
## 技术文档 ## 技术文档
* [SpringBlade开发手册一览](https://gitee.com/smallc/SpringBlade/wikis/SpringBlade开发手册)
* [SpringBlade常见问题集锦](https://sns.bladex.cn/article-14966.html)
* [SpringBlade基于Kuboard部署K8S](https://kuboard.cn/learning/k8s-practice/spring-blade/)
* [SpringBlade基于Rainbond部署](https://www.rainbond.com/docs/micro-service/example/blade)
## 项目地址 | 简介 | 地址 |
* 核心框架项目地址:[https://gitee.com/smallc/blade-tool](https://gitee.com/smallc/blade-tool) |---------------------------|--------------------------------------------------------------------------------------------------------------------------|
* 后端Gitee地址[https://gitee.com/smallc/SpringBlade](https://gitee.com/smallc/SpringBlade) | SpringBlade开发手册一览 | [https://gitee.com/smallc/SpringBlade/wikis/SpringBlade开发手册](https://gitee.com/smallc/SpringBlade/wikis/SpringBlade开发手册) |
* 后端Github地址[https://github.com/chillzhuang/SpringBlade](https://github.com/chillzhuang/SpringBlade) | SpringBlade常见问题集锦 | [https://sns.bladex.cn/article-14966.html](https://sns.bladex.cn/article-14966.html) |
* 后端SpringBoot版[https://gitee.com/smallc/SpringBlade/tree/boot/](https://gitee.com/smallc/SpringBlade/tree/boot/) | SpringBlade基于Kuboard部署K8S | [https://kuboard.cn/learning/k8s-practice/spring-blade/](https://kuboard.cn/learning/k8s-practice/spring-blade/) |
* 前端框架Sword(基于React)[https://gitee.com/smallc/Sword](https://gitee.com/smallc/Sword) | SpringBlade基于Rainbond部署 | [https://www.rainbond.com/docs/micro-service/example/blade](https://www.rainbond.com/docs/micro-service/example/blade) |
* 前端框架Saber(基于Vue)[https://gitee.com/smallc/Saber](https://gitee.com/smallc/Saber)
* 前端框架Saber3(基于Vue3)[https://gitee.com/smallc/Saber3](https://gitee.com/smallc/Saber/tree/3.x/)
# 开源协议
## 免费公开课
<table>
<tr>
<td><a href="https://space.bilibili.com/525525/channel/seriesdetail?sid=2740449" target="_blank"><img style="width: 300px; height: 170px" src="https://xbladex.oss-cn-hangzhou.aliyuncs.com/upload/springblade-course.jpg"/></a></td>
<td><img style="width: 300px; height: 170px" src="https://xbladex.oss-cn-hangzhou.aliyuncs.com/upload/springblade-bilibili.jpg"/></td>
</tr>
</table>
## 开源协议
Apache Licence 2.0 [英文原文](http://www.apache.org/licenses/LICENSE-2.0.html) Apache Licence 2.0 [英文原文](http://www.apache.org/licenses/LICENSE-2.0.html)
Apache Licence是著名的非盈利开源组织Apache采用的协议。该协议和BSD类似同样鼓励代码共享和尊重原作者的著作权同样允许代码修改再发布作为开源或商业软件 Apache Licence是著名的非盈利开源组织Apache采用的协议。该协议和BSD类似同样鼓励代码共享和尊重原作者的著作权同样允许代码修改再发布作为开源或商业软件
需要满足的条件如下: 需要满足的条件如下:
@ -76,102 +141,3 @@ Apache Licence是著名的非盈利开源组织Apache采用的协议。该协议
* 允许免费用于学习、毕设、公司项目、私活等,但请保留源码作者信息。 * 允许免费用于学习、毕设、公司项目、私活等,但请保留源码作者信息。
* 对未经过授权和不遵循 Apache 2.0 协议二次开源或者商业化我们将追究到底。 * 对未经过授权和不遵循 Apache 2.0 协议二次开源或者商业化我们将追究到底。
* 参考请注明:参考自 SpringBladehttps://gitee.com/smallc/SpringBlade。 * 参考请注明:参考自 SpringBladehttps://gitee.com/smallc/SpringBlade。
## 如何启动
```
$ git clone https://gitee.com/smallc/Sword.git
$ cd Sword
$ yarn install
# mock模式
$ yarn start:mock
# 服务模式
$ yarn run start 或者 yarn run start:no-mock
# 访问 http://localhost:1888
# 推荐使用yarn
```
# 界面
## [BladeX](https://bladex.cn/#/vip) 工作流一览
<table>
<tr>
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/bladex-flow1.png"/></td>
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/bladex-flow2.png"/></td>
</tr>
<tr>
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/bladex-flow3.png"/></td>
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/bladex-flow4.png"/></td>
</tr>
<tr>
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/bladex-flow5.png"/></td>
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/bladex-flow6.png"/></td>
</tr>
</table>
## [Sword](https://gitee.com/smallc/Sword) 界面一览
<table>
<tr>
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/sword-main.png"/></td>
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/sword-menu.png"/></td>
</tr>
<tr>
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/sword-menu-edit.png"/></td>
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/sword-menu-icon.png"/></td>
</tr>
<tr>
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/sword-role.png"/></td>
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/sword-user.png"/></td>
</tr>
<tr>
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/sword-dict.png "/></td>
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/sword-log.png"/></td>
</tr>
<tr>
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/sword-locale-cn.png"/></td>
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/sword-locale-us.png"/></td>
</tr>
</table>
## [Saber](https://gitee.com/smallc/Saber) 界面一览
<table>
<tr>
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/saber-user.png"/></td>
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/saber-role.png"/></td>
</tr>
<tr>
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/saber-dict.png"/></td>
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/saber-dict-select.png"/></td>
</tr>
<tr>
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/saber-log.png"/></td>
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/saber-code.png"/></td>
</tr>
</table>
## 监控界面一览
<table>
<tr>
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/springblade-k8s1.png"/></td>
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/springblade-k8s2.png"/></td>
</tr>
<tr>
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/springblade-grafana.png"/></td>
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/springblade-harbor.png"/></td>
</tr>
<tr>
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/springblade-traefik.png"/></td>
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/springblade-traefik-health.png"/></td>
</tr>
<tr>
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/springblade-nacos.png"/></td>
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/springblade-sentinel.png"/></td>
</tr>
<tr>
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/springblade-admin1.png"/></td>
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/springblade-admin2.png"/></td>
</tr>
<tr>
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/springblade-swagger1.png"/></td>
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/springblade-swagger2.png"/></td>
</tr>
</table>

View File

@ -1,11 +1,11 @@
{ {
"name": "sword-admin", "name": "sword-admin",
"version": "4.0.0", "version": "4.1.0",
"description": "An out-of-box UI solution for enterprise applications", "description": "An out-of-box UI solution for enterprise applications",
"private": true, "private": true,
"scripts": { "scripts": {
"presite": "cd functions && npm install", "presite": "cd functions && npm install",
"start": "cross-env MOCK=none PORT=1888 umi dev", "start": "export NODE_OPTIONS=--openssl-legacy-provider && cross-env MOCK=none PORT=1888 umi dev",
"start:no-mock": "cross-env MOCK=none PORT=1888 umi dev", "start:no-mock": "cross-env MOCK=none PORT=1888 umi dev",
"start:mock": "cross-env APP_TYPE=site PORT=1888 umi dev", "start:mock": "cross-env APP_TYPE=site PORT=1888 umi dev",
"build": "umi build", "build": "umi build",
@ -39,6 +39,7 @@
"bizcharts-plugin-slider": "^2.1.1-beta.1", "bizcharts-plugin-slider": "^2.1.1-beta.1",
"classnames": "^2.2.6", "classnames": "^2.2.6",
"crypto-js": "^4.0.0", "crypto-js": "^4.0.0",
"sm-crypto": "^0.3.13",
"dva": "^2.4.1", "dva": "^2.4.1",
"enquire-js": "^0.2.1", "enquire-js": "^0.2.1",
"hash.js": "^1.1.7", "hash.js": "^1.1.7",

View File

@ -16,6 +16,10 @@ module.exports = {
disableLocal: false, disableLocal: false,
}, },
pwa: true, pwa: true,
auth: {
// 使用后端工程 @org.springblade.test.Sm2KeyGenerator 获取
publicKey: '04e6862d0819ec55e9d7d8bb961ccc8c2b7d86b6845ac333d1d9ab8af6a892cebb3d30f952da4111971908eb02829459170bdd338e7a27fa57d6300dc290d052b5',
},
// 第三方登陆授权地址 // 第三方登陆授权地址
authUrl: 'http://localhost/blade-auth/oauth/render', authUrl: 'http://localhost/blade-auth/oauth/render',
// 报表设计器地址(cloud端口为8108,boot端口为80) // 报表设计器地址(cloud端口为8108,boot端口为80)

View File

@ -20,7 +20,7 @@ class Workplace extends PureComponent {
<Row gutter={24}> <Row gutter={24}>
<Col span={24}> <Col span={24}>
<div style={{ textAlign: 'center' }}> <div style={{ textAlign: 'center' }}>
<img src="https://img.shields.io/badge/Release-V4.0.0-green.svg" alt="Downloads" /> <img src="https://img.shields.io/badge/Release-V4.1.0-green.svg" alt="Downloads" />
<img src="https://img.shields.io/badge/JDK-17+-green.svg" alt="Build Status" /> <img src="https://img.shields.io/badge/JDK-17+-green.svg" alt="Build Status" />
<img <img
src="https://img.shields.io/badge/Spring%20Cloud-2023-blue.svg" src="https://img.shields.io/badge/Spring%20Cloud-2023-blue.svg"
@ -212,7 +212,20 @@ class Workplace extends PureComponent {
</Row> </Row>
<Row gutter={24}> <Row gutter={24}>
<Card className={styles.card} bordered={false}> <Card className={styles.card} bordered={false}>
<Collapse bordered={false} defaultActiveKey={['36']}> <Collapse bordered={false} defaultActiveKey={['37']}>
<Panel header="4.1.0发布 登录认证升级国密算法数据库password字段无需变动" key="37">
<div>1.[升级]SpringBoot 3.2.7</div>
<div>2.[升级]SpringCloud 2023.0.2</div>
<div>3.[升级]AlibabaCloud 2023.0.1.0</div>
<div>4.[升级]Nacos 2.3.2</div>
<div>5.[升级]MybatisPlus 3.5.7</div>
<div>6.[新增]登录认证升级为国密sm2算法数据库字段无需变动</div>
<div>7.[新增]oss内网上传后转换返回外网地址</div>
<div>8.[新增]saber2与saber3支持nodejs18编译</div>
<div>9.[优化]完善swagger与springdoc的配置</div>
<div>10.[优化]重构StringUtil的format方法</div>
<div>11.[优化]saveOrUpdate方法增加业务字段更新逻辑</div>
</Panel>
<Panel header="4.0.0发布 升级 SpringBoot3 SpringCloud2023 JDK17" key="36"> <Panel header="4.0.0发布 升级 SpringBoot3 SpringCloud2023 JDK17" key="36">
<div>1.[升级]JDK Java17</div> <div>1.[升级]JDK Java17</div>
<div>2.[升级]SpringBoot 3.2.4</div> <div>2.[升级]SpringBoot 3.2.4</div>

View File

@ -3,11 +3,13 @@ import request from '../utils/request';
import func from '../utils/Func'; import func from '../utils/Func';
import { getCaptchaKey } from '../utils/authority'; import { getCaptchaKey } from '../utils/authority';
import { captchaMode } from '../defaultSettings'; import { captchaMode } from '../defaultSettings';
import encrypt from '../utils/sm2'
// =====================用户=========================== // =====================用户===========================
export async function accountLogin(params) { export async function accountLogin(params) {
const values = params; const values = params;
values.password = encrypt(params.password);
values.grantType = captchaMode ? 'captcha' : 'password'; values.grantType = captchaMode ? 'captcha' : 'password';
values.scope = 'all'; values.scope = 'all';
return request('/api/blade-auth/token', { return request('/api/blade-auth/token', {

16
src/utils/sm2.js Normal file
View File

@ -0,0 +1,16 @@
import { sm2 } from 'sm-crypto';
import { auth } from '../defaultSettings';
/**
* sm2 加密方法
* @param data
* @returns {*}
*/
export default function encrypt(data) {
try {
return sm2.doEncrypt(data, auth.publicKey, 0);
} catch {
return '';
}
}