feat: 内部请求时不进行数据权限过滤

docs: 数据库isPublic字段增加 #324
This commit is contained in:
qiufeng
2025-03-17 18:15:30 +08:00
parent a212f4f67f
commit 3930ffaa36
14 changed files with 57 additions and 42 deletions
+18 -17
View File
@@ -1015,23 +1015,24 @@ CREATE TABLE `sys_config` (
-- ----------------------------
DROP TABLE IF EXISTS `sys_db_connect`;
CREATE TABLE `sys_db_connect` (
`id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '库信息id',
`tenant_id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '租户ID',
`db_title` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '数据库标题',
`db_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '数据库名',
`db_type` tinyint(1) NULL DEFAULT NULL COMMENT '数据库类型(0 mysql 1 oracle 2 pgsql',
`pool_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '连接池类型(Druid,Hikari)',
`host` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '主机',
`port` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '端口号',
`username` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '数据库登录用户名',
`password` varchar(300) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '数据库登录密码',
`options` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '数据源配置项(JSON格式)',
`remark` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
`create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建人',
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
`update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '修改人',
`update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
PRIMARY KEY (`id`) USING BTREE
`id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '库信息id',
`tenant_id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '租户ID',
`db_title` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '数据库标题',
`db_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '数据库名',
`db_type` tinyint(1) NULL DEFAULT NULL COMMENT '数据库类型(0 mysql 1 oracle 2 pgsql',
`pool_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '连接池类型(Druid,Hikari)',
`host` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '主机',
`port` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '端口号',
`username` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '数据库登录用户名',
`password` varchar(300) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '数据库登录密码',
`options` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '数据源配置项(JSON格式)',
`is_public` tinyint(1) NULL DEFAULT 0 COMMENT '是否公开连接 0为私有的 1公开的',
`remark` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
`create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建',
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
`update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '修改',
`update_time` datetime NULL DEFAULT NULL COMMENT '修改时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '数据库连接信息' ROW_FORMAT = DYNAMIC;
+8
View File
@@ -81,5 +81,13 @@
<groupId>cn.idev.excel</groupId>
<artifactId>fastexcel</artifactId>
</dependency>
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>core</artifactId>
</dependency>
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>javase</artifactId>
</dependency>
</dependencies>
</project>
@@ -2,8 +2,10 @@ package cn.com.mfish.common.core.utils;
import cn.com.mfish.common.core.constants.Constants;
import cn.com.mfish.common.core.constants.RPCConstants;
import cn.com.mfish.common.core.exception.MyRuntimeException;
import cn.com.mfish.common.core.exception.OAuthValidateException;
import cn.com.mfish.common.core.utils.http.WebRequest;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
@@ -177,4 +179,18 @@ public class AuthInfoUtils {
}
return roleIds.stream().anyMatch(AuthInfoUtils::isSuperRole);
}
/**
* 是否内部请求
*
* @return 是否
*/
public static boolean isInnerRequest() {
HttpServletRequest request = ServletUtils.getRequest();
if (request == null) {
throw new MyRuntimeException("错误:未获取到请求信息");
}
String source = request.getHeader(RPCConstants.REQ_ORIGIN);
return !StringUtils.isEmpty(source) && source.equals(RPCConstants.INNER);
}
}
@@ -1,6 +1,5 @@
package cn.com.mfish.oauth.common;
package cn.com.mfish.common.core.utils;
import cn.com.mfish.common.core.utils.StringUtils;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType;
import com.google.zxing.MultiFormatWriter;
@@ -70,7 +69,7 @@ public class QRCodeUtils {
Hashtable<EncodeHintType, Object> hints = new Hashtable<>();
hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);
hints.put(EncodeHintType.CHARACTER_SET, CHARSET);
hints.put(EncodeHintType.MARGIN, 2);
hints.put(EncodeHintType.MARGIN, 0);
BitMatrix bitMatrix = new MultiFormatWriter().encode(content, BarcodeFormat.QR_CODE, QRCODE_SIZE, QRCODE_SIZE, hints);
int width = bitMatrix.getWidth();
int height = bitMatrix.getHeight();
@@ -1,13 +1,10 @@
package cn.com.mfish.common.oauth.aspect;
import cn.com.mfish.common.core.constants.RPCConstants;
import cn.com.mfish.common.core.exception.MyRuntimeException;
import cn.com.mfish.common.core.utils.ServletUtils;
import cn.com.mfish.common.core.utils.StringUtils;
import cn.com.mfish.common.core.utils.AuthInfoUtils;
import cn.com.mfish.common.oauth.annotation.RequiresPermissions;
import cn.com.mfish.common.oauth.annotation.RequiresRoles;
import cn.com.mfish.common.oauth.common.OauthUtils;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
@@ -29,13 +26,8 @@ public class AuthorizationAspect {
@Before("@annotation(cn.com.mfish.common.oauth.annotation.RequiresPermissions)" +
"||@annotation(cn.com.mfish.common.oauth.annotation.RequiresRoles)")
public void doBefore(JoinPoint joinPoint) {
HttpServletRequest request = ServletUtils.getRequest();
if (request == null) {
throw new MyRuntimeException("错误:未获取到请求信息");
}
String source = request.getHeader(RPCConstants.REQ_ORIGIN);
//判断如果是内部Feign接口请求不需要验证按钮权限
if (!StringUtils.isEmpty(source) && source.equals(RPCConstants.INNER)) {
if(AuthInfoUtils.isInnerRequest()){
return;
}
MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
@@ -1,6 +1,7 @@
package cn.com.mfish.common.oauth.aspect;
import cn.com.mfish.common.core.annotation.GlobalException;
import cn.com.mfish.common.core.utils.AuthInfoUtils;
import cn.com.mfish.common.oauth.annotation.DataScope;
import cn.com.mfish.common.oauth.annotation.DataScopes;
import cn.com.mfish.common.oauth.common.DataScopeUtils;
@@ -31,6 +32,10 @@ public class DataScopeAspect {
@Before("@annotation(cn.com.mfish.common.oauth.annotation.DataScopes)||@annotation(cn.com.mfish.common.oauth.annotation.DataScope)")
public void doBefore(JoinPoint joinPoint) {
// 内部Feign请求不进行数据权限限制
if (AuthInfoUtils.isInnerRequest()) {
return;
}
MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
Method method = methodSignature.getMethod();
List<DataScope> list = new ArrayList<>();
-8
View File
@@ -30,14 +30,6 @@
<artifactId>shiro-web</artifactId>
<classifier>jakarta</classifier>
</dependency>
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>core</artifactId>
</dependency>
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>javase</artifactId>
</dependency>
<dependency>
<groupId>com.github.binarywang</groupId>
<artifactId>weixin-java-miniapp</artifactId>
@@ -7,7 +7,7 @@ import cn.com.mfish.common.core.web.Result;
import cn.com.mfish.common.oauth.common.SerConstant;
import cn.com.mfish.common.oauth.entity.WeChatToken;
import cn.com.mfish.common.oauth.validator.WeChatTokenValidator;
import cn.com.mfish.oauth.common.QRCodeUtils;
import cn.com.mfish.common.core.utils.QRCodeUtils;
import cn.com.mfish.oauth.entity.QRCode;
import cn.com.mfish.oauth.entity.QRCodeImg;
import cn.com.mfish.oauth.entity.RedisQrCode;
@@ -165,8 +165,10 @@ html, body {
}
.login .qrcode-img .qrcode {
border-color: transparent;
margin: 8px;
padding: 12px;
box-shadow: 0 0 8px #c6c4ce;
border-radius: 8px;
width: 240px;
height: 240px;
}
Binary file not shown.
Binary file not shown.
+2 -2
View File
@@ -47,9 +47,9 @@
<wechat.version>4.6.7.B</wechat.version>
<aliyun-oss.version>3.18.1</aliyun-oss.version>
<qiniu-sdk.version>7.17.0</qiniu-sdk.version>
<rocketmq.version>2.3.1</rocketmq.version>
<rocketmq.version>2.3.2</rocketmq.version>
<bcprov.version>1.79</bcprov.version>
<oracle.version>23.5.0.24.07</oracle.version>
<oracle.version>23.7.0.25.01</oracle.version>
<pgsql.version>42.7.4</pgsql.version>
<mssql.version>12.8.1.jre11</mssql.version>
<fastexcel.version>1.1.0</fastexcel.version>