diff --git a/jeecg-boot-base-core/pom.xml b/jeecg-boot-base-core/pom.xml
index 018a026c0..738728d09 100644
--- a/jeecg-boot-base-core/pom.xml
+++ b/jeecg-boot-base-core/pom.xml
@@ -173,63 +173,6 @@
${java-jwt.version}
-
-
- org.apache.shiro
- shiro-spring-boot-starter
- ${shiro.version}
-
-
- org.apache.shiro
- shiro-spring
-
-
-
-
-
- org.crazycake
- shiro-redis
- ${shiro-redis.version}
-
-
- org.apache.shiro
- shiro-core
-
-
- checkstyle
- com.puppycrawl.tools
-
-
-
- jedis
- redis.clients
-
-
-
-
-
- redis.clients
- jedis
- 2.9.0
-
-
-
- org.apache.shiro
- shiro-spring
- jakarta
- ${shiro.version}
-
-
-
- org.apache.shiro
- shiro-core
-
-
- org.apache.shiro
- shiro-web
-
-
-
org.springframework.boot
@@ -244,25 +187,6 @@
org.springframework.security
spring-security-cas
-
-
- org.apache.shiro
- shiro-core
- jakarta
- ${shiro.version}
-
-
- org.apache.shiro
- shiro-web
- jakarta
- ${shiro.version}
-
-
- org.apache.shiro
- shiro-core
-
-
-
diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/exception/JeecgBootExceptionHandler.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/exception/JeecgBootExceptionHandler.java
index f69b8d049..67f96fec9 100644
--- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/exception/JeecgBootExceptionHandler.java
+++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/exception/JeecgBootExceptionHandler.java
@@ -2,8 +2,6 @@ package org.jeecg.common.exception;
import cn.hutool.core.util.ObjectUtil;
import lombok.extern.slf4j.Slf4j;
-import org.apache.shiro.authz.AuthorizationException;
-import org.apache.shiro.authz.UnauthorizedException;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.enums.SentinelErrorInfoEnum;
import org.springframework.dao.DataIntegrityViolationException;
@@ -87,12 +85,6 @@ public class JeecgBootExceptionHandler {
return Result.error("数据库中已存在该记录");
}
- @ExceptionHandler({UnauthorizedException.class, AuthorizationException.class})
- public Result> handleAuthorizationException(AuthorizationException e){
- log.error(e.getMessage(), e);
- return Result.noauth("没有权限,请联系管理员授权");
- }
-
@ExceptionHandler(AccessDeniedException.class)
public Result> handleAuthorizationException(AccessDeniedException e){
log.error(e.getMessage(), e);
diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/system/base/controller/JeecgController.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/system/base/controller/JeecgController.java
index 4f703754d..b143c4ac5 100644
--- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/system/base/controller/JeecgController.java
+++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/system/base/controller/JeecgController.java
@@ -7,7 +7,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.beanutils.PropertyUtils;
-import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.system.vo.LoginUser;
diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/encryption/AesEncryptUtil.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/encryption/AesEncryptUtil.java
index 670f3ebd6..e75092cca 100644
--- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/encryption/AesEncryptUtil.java
+++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/encryption/AesEncryptUtil.java
@@ -1,10 +1,9 @@
package org.jeecg.common.util.encryption;
-import org.apache.shiro.codec.Base64;
-
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
+import java.util.Base64;
/**
* @Description: AES 加密
@@ -49,7 +48,7 @@ public class AesEncryptUtil {
cipher.init(Cipher.ENCRYPT_MODE, keyspec, ivspec);
byte[] encrypted = cipher.doFinal(plaintext);
- return Base64.encodeToString(encrypted);
+ return Base64.getEncoder().encodeToString(encrypted);
} catch (Exception e) {
e.printStackTrace();
@@ -67,7 +66,7 @@ public class AesEncryptUtil {
*/
public static String desEncrypt(String data, String key, String iv) throws Exception {
//update-begin-author:taoyan date:2022-5-23 for:VUEN-1084 【vue3】online表单测试发现的新问题 6、解密报错 ---解码失败应该把异常抛出去,在外面处理
- byte[] encrypted1 = Base64.decode(data);
+ byte[] encrypted1 = Base64.getDecoder().decode(data);
Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding");
SecretKeySpec keyspec = new SecretKeySpec(key.getBytes(), "AES");
diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/config/JeecgBaseConfig.java b/jeecg-boot-base-core/src/main/java/org/jeecg/config/JeecgBaseConfig.java
index 4597d216b..a6cb28e5f 100644
--- a/jeecg-boot-base-core/src/main/java/org/jeecg/config/JeecgBaseConfig.java
+++ b/jeecg-boot-base-core/src/main/java/org/jeecg/config/JeecgBaseConfig.java
@@ -32,10 +32,6 @@ public class JeecgBaseConfig {
*/
private Firewall firewall;
- /**
- * shiro拦截排除
- */
- private Shiro shiro;
/**
* 上传文件配置
*/
@@ -88,14 +84,6 @@ public class JeecgBaseConfig {
this.signatureSecret = signatureSecret;
}
- public Shiro getShiro() {
- return shiro;
- }
-
- public void setShiro(Shiro shiro) {
- this.shiro = shiro;
- }
-
public Path getPath() {
return path;
}
diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/config/firewall/interceptor/LowCodeModeInterceptor.java b/jeecg-boot-base-core/src/main/java/org/jeecg/config/firewall/interceptor/LowCodeModeInterceptor.java
index 071d14068..404e24e42 100644
--- a/jeecg-boot-base-core/src/main/java/org/jeecg/config/firewall/interceptor/LowCodeModeInterceptor.java
+++ b/jeecg-boot-base-core/src/main/java/org/jeecg/config/firewall/interceptor/LowCodeModeInterceptor.java
@@ -2,7 +2,6 @@ package org.jeecg.config.firewall.interceptor;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
-import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.CommonAPI;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.constant.CommonConstant;
@@ -11,6 +10,7 @@ import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.CommonUtils;
import org.jeecg.common.util.SpringContextUtils;
import org.jeecg.config.JeecgBaseConfig;
+import org.jeecg.config.security.utils.SecureUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.servlet.HandlerInterceptor;
@@ -63,7 +63,7 @@ public class LowCodeModeInterceptor implements HandlerInterceptor {
if (jeecgBaseConfig.getFirewall()!=null && LowCodeModeInterceptor.LOW_CODE_MODE_PROD.equals(jeecgBaseConfig.getFirewall().getLowCodeMode())) {
String requestURI = request.getRequestURI().substring(request.getContextPath().length());
log.info("低代码模式,拦截请求路径:" + requestURI);
- LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+ LoginUser loginUser = SecureUtil.currentUser();
Set hasRoles = null;
if (loginUser == null) {
loginUser = commonAPI.getUserByName(JwtUtil.getUserNameByToken(SpringContextUtils.getHttpServletRequest()));
diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/config/mybatis/MybatisInterceptor.java b/jeecg-boot-base-core/src/main/java/org/jeecg/config/mybatis/MybatisInterceptor.java
index 90cca20bb..825d0f250 100644
--- a/jeecg-boot-base-core/src/main/java/org/jeecg/config/mybatis/MybatisInterceptor.java
+++ b/jeecg-boot-base-core/src/main/java/org/jeecg/config/mybatis/MybatisInterceptor.java
@@ -6,11 +6,11 @@ import org.apache.ibatis.executor.Executor;
import org.apache.ibatis.mapping.MappedStatement;
import org.apache.ibatis.mapping.SqlCommandType;
import org.apache.ibatis.plugin.*;
-import org.apache.shiro.SecurityUtils;
import org.jeecg.common.config.TenantContext;
import org.jeecg.common.constant.TenantConstant;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.oConvertUtils;
+import org.jeecg.config.security.utils.SecureUtil;
import org.springframework.stereotype.Component;
import java.lang.reflect.Field;
@@ -173,7 +173,7 @@ public class MybatisInterceptor implements Interceptor {
private LoginUser getLoginUser() {
LoginUser sysUser = null;
try {
- sysUser = SecurityUtils.getSubject().getPrincipal() != null ? (LoginUser) SecurityUtils.getSubject().getPrincipal() : null;
+ sysUser = SecureUtil.currentUser() != null ? SecureUtil.currentUser() : null;
} catch (Exception e) {
//e.printStackTrace();
sysUser = null;
diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/JwtToken.java b/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/JwtToken.java
deleted file mode 100644
index 0507c5416..000000000
--- a/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/JwtToken.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package org.jeecg.config.shiro;
-
-import org.apache.shiro.authc.AuthenticationToken;
-
-/**
- * @Author Scott
- * @create 2018-07-12 15:19
- * @desc
- **/
-public class JwtToken implements AuthenticationToken {
-
- private static final long serialVersionUID = 1L;
- private String token;
-
- public JwtToken(String token) {
- this.token = token;
- }
-
- @Override
- public Object getPrincipal() {
- return token;
- }
-
- @Override
- public Object getCredentials() {
- return token;
- }
-}
diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java b/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java
deleted file mode 100644
index 136751b7c..000000000
--- a/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java
+++ /dev/null
@@ -1,301 +0,0 @@
-package org.jeecg.config.shiro;
-
-import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
-import org.apache.shiro.mgt.DefaultSessionStorageEvaluator;
-import org.apache.shiro.mgt.DefaultSubjectDAO;
-import org.apache.shiro.mgt.SecurityManager;
-import org.apache.shiro.spring.LifecycleBeanPostProcessor;
-import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor;
-import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
-import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
-import org.crazycake.shiro.*;
-import org.jeecg.common.constant.CommonConstant;
-import org.jeecg.common.util.oConvertUtils;
-import org.jeecg.config.JeecgBaseConfig;
-import org.jeecg.config.shiro.filters.CustomShiroFilterFactoryBean;
-import org.jeecg.config.shiro.filters.JwtFilter;
-import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.DependsOn;
-import org.springframework.core.env.Environment;
-import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
-import org.springframework.util.CollectionUtils;
-import org.springframework.util.StringUtils;
-import redis.clients.jedis.HostAndPort;
-import redis.clients.jedis.JedisCluster;
-
-import jakarta.annotation.Resource;
-import jakarta.servlet.Filter;
-import java.util.*;
-import java.util.stream.Collectors;
-
-/**
- * @author: Scott
- * @date: 2018/2/7
- * @description: shiro 配置类
- */
-
-@Slf4j
-//@Configuration
-public class ShiroConfig {
-
- @Resource
- private LettuceConnectionFactory lettuceConnectionFactory;
- @Autowired
- private Environment env;
- @Resource
- private JeecgBaseConfig jeecgBaseConfig;
- @Autowired(required = false)
- private RedisProperties redisProperties;
-
- /**
- * Filter Chain定义说明
- *
- * 1、一个URL可以配置多个Filter,使用逗号分隔
- * 2、当设置多个过滤器时,全部验证通过,才视为通过
- * 3、部分过滤器可指定参数,如perms,roles
- */
- @Bean("shiroFilterFactoryBean")
- public ShiroFilterFactoryBean shiroFilter(SecurityManager securityManager) {
- CustomShiroFilterFactoryBean shiroFilterFactoryBean = new CustomShiroFilterFactoryBean();
- shiroFilterFactoryBean.setSecurityManager(securityManager);
- // 拦截器
- Map filterChainDefinitionMap = new LinkedHashMap();
-
- //支持yml方式,配置拦截排除
- if(jeecgBaseConfig!=null && jeecgBaseConfig.getShiro()!=null){
- String shiroExcludeUrls = jeecgBaseConfig.getShiro().getExcludeUrls();
- if(oConvertUtils.isNotEmpty(shiroExcludeUrls)){
- String[] permissionUrl = shiroExcludeUrls.split(",");
- for(String url : permissionUrl){
- filterChainDefinitionMap.put(url,"anon");
- }
- }
- }
- // 配置不会被拦截的链接 顺序判断
- filterChainDefinitionMap.put("/sys/cas/client/validateLogin", "anon"); //cas验证登录
- filterChainDefinitionMap.put("/sys/randomImage/**", "anon"); //登录验证码接口排除
- filterChainDefinitionMap.put("/sys/checkCaptcha", "anon"); //登录验证码接口排除
- filterChainDefinitionMap.put("/sys/login", "anon"); //登录接口排除
- filterChainDefinitionMap.put("/sys/mLogin", "anon"); //登录接口排除
- filterChainDefinitionMap.put("/sys/logout", "anon"); //登出接口排除
- filterChainDefinitionMap.put("/sys/thirdLogin/**", "anon"); //第三方登录
- filterChainDefinitionMap.put("/sys/getEncryptedString", "anon"); //获取加密串
- filterChainDefinitionMap.put("/sys/sms", "anon");//短信验证码
- filterChainDefinitionMap.put("/sys/phoneLogin", "anon");//手机登录
- filterChainDefinitionMap.put("/sys/user/checkOnlyUser", "anon");//校验用户是否存在
- filterChainDefinitionMap.put("/sys/user/register", "anon");//用户注册
- filterChainDefinitionMap.put("/sys/user/phoneVerification", "anon");//用户忘记密码验证手机号
- filterChainDefinitionMap.put("/sys/user/passwordChange", "anon");//用户更改密码
- filterChainDefinitionMap.put("/auth/2step-code", "anon");//登录验证码
- filterChainDefinitionMap.put("/sys/common/static/**", "anon");//图片预览 &下载文件不限制token
- filterChainDefinitionMap.put("/sys/common/pdf/**", "anon");//pdf预览
- filterChainDefinitionMap.put("/generic/**", "anon");//pdf预览需要文件
-
- filterChainDefinitionMap.put("/sys/getLoginQrcode/**", "anon"); //登录二维码
- filterChainDefinitionMap.put("/sys/getQrcodeToken/**", "anon"); //监听扫码
- filterChainDefinitionMap.put("/sys/checkAuth", "anon"); //授权接口排除
-
-
- filterChainDefinitionMap.put("/", "anon");
- filterChainDefinitionMap.put("/doc.html", "anon");
- filterChainDefinitionMap.put("/**/*.js", "anon");
- filterChainDefinitionMap.put("/**/*.css", "anon");
- filterChainDefinitionMap.put("/**/*.html", "anon");
- filterChainDefinitionMap.put("/**/*.svg", "anon");
- filterChainDefinitionMap.put("/**/*.pdf", "anon");
- filterChainDefinitionMap.put("/**/*.jpg", "anon");
- filterChainDefinitionMap.put("/**/*.png", "anon");
- filterChainDefinitionMap.put("/**/*.gif", "anon");
- filterChainDefinitionMap.put("/**/*.ico", "anon");
- filterChainDefinitionMap.put("/**/*.ttf", "anon");
- filterChainDefinitionMap.put("/**/*.woff", "anon");
- filterChainDefinitionMap.put("/**/*.woff2", "anon");
-
- filterChainDefinitionMap.put("/druid/**", "anon");
- filterChainDefinitionMap.put("/swagger-ui.html", "anon");
- filterChainDefinitionMap.put("/swagger**/**", "anon");
- filterChainDefinitionMap.put("/webjars/**", "anon");
- filterChainDefinitionMap.put("/v3/**", "anon");
- // 企业微信证书排除
- filterChainDefinitionMap.put("/WW_verify*", "anon");
-
- filterChainDefinitionMap.put("/sys/annountCement/show/**", "anon");
-
- //积木报表排除
- filterChainDefinitionMap.put("/jmreport/**", "anon");
- filterChainDefinitionMap.put("/**/*.js.map", "anon");
- filterChainDefinitionMap.put("/**/*.css.map", "anon");
-
- //拖拽仪表盘设计器排除
- filterChainDefinitionMap.put("/drag/view", "anon");
- filterChainDefinitionMap.put("/drag/page/queryById", "anon");
- filterChainDefinitionMap.put("/drag/onlDragDatasetHead/getAllChartData", "anon");
- filterChainDefinitionMap.put("/drag/onlDragDatasetHead/getTotalData", "anon");
- filterChainDefinitionMap.put("/drag/mock/json/**", "anon");
- //大屏模板例子
- filterChainDefinitionMap.put("/test/bigScreen/**", "anon");
- filterChainDefinitionMap.put("/bigscreen/template1/**", "anon");
- filterChainDefinitionMap.put("/bigscreen/template1/**", "anon");
- //filterChainDefinitionMap.put("/test/jeecgDemo/rabbitMqClientTest/**", "anon"); //MQ测试
- //filterChainDefinitionMap.put("/test/jeecgDemo/html", "anon"); //模板页面
- //filterChainDefinitionMap.put("/test/jeecgDemo/redis/**", "anon"); //redis测试
-
- //websocket排除
- filterChainDefinitionMap.put("/websocket/**", "anon");//系统通知和公告
- filterChainDefinitionMap.put("/newsWebsocket/**", "anon");//CMS模块
- filterChainDefinitionMap.put("/vxeSocket/**", "anon");//JVxeTable无痕刷新示例
-
- //性能监控——安全隐患泄露TOEKN(durid连接池也有)
- //filterChainDefinitionMap.put("/actuator/**", "anon");
- //测试模块排除
- filterChainDefinitionMap.put("/test/seata/**", "anon");
-
- // update-begin--author:liusq Date:20230522 for:[issues/4829]访问不存在的url时会提示Token失效,请重新登录呢
- //错误路径排除
- filterChainDefinitionMap.put("/error", "anon");
- // update-end--author:liusq Date:20230522 for:[issues/4829]访问不存在的url时会提示Token失效,请重新登录呢
-
- // 添加自己的过滤器并且取名为jwt
- Map filterMap = new HashMap(1);
- //如果cloudServer为空 则说明是单体 需要加载跨域配置【微服务跨域切换】
- Object cloudServer = env.getProperty(CommonConstant.CLOUD_SERVER_KEY);
- filterMap.put("jwt", new JwtFilter(cloudServer==null));
- shiroFilterFactoryBean.setFilters(filterMap);
- //
- 1.12.0
3.11.0
- 3.2.2
1.4.4
1.4.7
8.5.7