From b60942aa86c382420b0ba9dfeb0242fc78ccc571 Mon Sep 17 00:00:00 2001 From: EightMonth Date: Thu, 24 Oct 2024 10:48:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E5=B8=83=E5=BC=8F=E4=BA=8B=E5=8A=A1de?= =?UTF-8?q?mo=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/security/JeecgAuthenticationConvert.java | 8 +++++--- .../jeecg/config/security/JeecgPermissionService.java | 10 +++++++--- .../security/app/AppGrantAuthenticationProvider.java | 2 ++ .../password/PasswordGrantAuthenticationProvider.java | 2 ++ .../phone/PhoneGrantAuthenticationProvider.java | 2 ++ .../security/self/SelfAuthenticationProvider.java | 5 ++--- .../social/SocialGrantAuthenticationProvider.java | 2 ++ 7 files changed, 22 insertions(+), 9 deletions(-) diff --git a/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/config/security/JeecgAuthenticationConvert.java b/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/config/security/JeecgAuthenticationConvert.java index d7c3c2138..321f21578 100644 --- a/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/config/security/JeecgAuthenticationConvert.java +++ b/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/config/security/JeecgAuthenticationConvert.java @@ -1,8 +1,9 @@ package org.jeecg.config.security; -import lombok.RequiredArgsConstructor; import org.jeecg.common.api.CommonAPI; import org.jeecg.common.system.vo.LoginUser; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Lazy; import org.springframework.core.convert.converter.Converter; import org.springframework.security.authentication.AbstractAuthenticationToken; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; @@ -18,10 +19,11 @@ import java.util.ArrayList; * @date 2024/7/15 11:05 */ @Component -@RequiredArgsConstructor public class JeecgAuthenticationConvert implements Converter { - private final CommonAPI commonAPI; + @Lazy + @Autowired + private CommonAPI commonAPI; @Override public AbstractAuthenticationToken convert(Jwt source) { diff --git a/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/config/security/JeecgPermissionService.java b/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/config/security/JeecgPermissionService.java index 46a5d3b17..8beaab02f 100644 --- a/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/config/security/JeecgPermissionService.java +++ b/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/config/security/JeecgPermissionService.java @@ -7,6 +7,8 @@ import org.jeecg.common.api.CommonAPI; import org.jeecg.common.system.vo.LoginUser; import org.jeecg.common.util.RedisUtil; import org.jeecg.config.security.utils.SecureUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.util.PatternMatchUtils; import org.springframework.util.StringUtils; @@ -21,14 +23,16 @@ import java.util.Set; * @date 2024/1/10 17:00 */ @Service("jps") -@AllArgsConstructor @Slf4j public class JeecgPermissionService { private final String SPLIT = "::"; private final String PERM_PREFIX = "jps" + SPLIT; - private final CommonAPI commonAPI; - private final RedisUtil redisUtil; + @Lazy + @Autowired + private CommonAPI commonAPI; + @Autowired + private RedisUtil redisUtil; /** * 判断接口是否有任意xxx,xxx权限 diff --git a/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/config/security/app/AppGrantAuthenticationProvider.java b/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/config/security/app/AppGrantAuthenticationProvider.java index 7d36f07a7..ccf2f03b5 100644 --- a/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/config/security/app/AppGrantAuthenticationProvider.java +++ b/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/config/security/app/AppGrantAuthenticationProvider.java @@ -17,6 +17,7 @@ import org.jeecg.config.JeecgBaseConfig; import org.jeecg.config.security.password.PasswordGrantAuthenticationToken; import org.jeecg.modules.base.service.BaseCommonService; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Lazy; import org.springframework.http.HttpStatus; import org.springframework.security.authentication.AuthenticationProvider; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; @@ -55,6 +56,7 @@ public class AppGrantAuthenticationProvider implements AuthenticationProvider { private final OAuth2AuthorizationService authorizationService; private final OAuth2TokenGenerator tokenGenerator; + @Lazy @Autowired private CommonAPI commonAPI; @Autowired diff --git a/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/config/security/password/PasswordGrantAuthenticationProvider.java b/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/config/security/password/PasswordGrantAuthenticationProvider.java index d5c0a2874..e3341df67 100644 --- a/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/config/security/password/PasswordGrantAuthenticationProvider.java +++ b/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/config/security/password/PasswordGrantAuthenticationProvider.java @@ -16,6 +16,7 @@ import org.jeecg.common.util.oConvertUtils; import org.jeecg.config.JeecgBaseConfig; import org.jeecg.modules.base.service.BaseCommonService; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Lazy; import org.springframework.http.HttpStatus; import org.springframework.security.authentication.AuthenticationProvider; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; @@ -56,6 +57,7 @@ public class PasswordGrantAuthenticationProvider implements AuthenticationProvid private final OAuth2AuthorizationService authorizationService; private final OAuth2TokenGenerator tokenGenerator; + @Lazy @Autowired private CommonAPI commonAPI; @Autowired diff --git a/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/config/security/phone/PhoneGrantAuthenticationProvider.java b/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/config/security/phone/PhoneGrantAuthenticationProvider.java index ec73cec16..ffe0e36d6 100644 --- a/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/config/security/phone/PhoneGrantAuthenticationProvider.java +++ b/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/config/security/phone/PhoneGrantAuthenticationProvider.java @@ -16,6 +16,7 @@ import org.jeecg.config.JeecgBaseConfig; import org.jeecg.config.security.password.PasswordGrantAuthenticationToken; import org.jeecg.modules.base.service.BaseCommonService; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Lazy; import org.springframework.http.HttpStatus; import org.springframework.security.authentication.AuthenticationProvider; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; @@ -53,6 +54,7 @@ public class PhoneGrantAuthenticationProvider implements AuthenticationProvider private final OAuth2AuthorizationService authorizationService; private final OAuth2TokenGenerator tokenGenerator; + @Lazy @Autowired private CommonAPI commonAPI; @Autowired diff --git a/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/config/security/self/SelfAuthenticationProvider.java b/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/config/security/self/SelfAuthenticationProvider.java index 3a0b53a75..c031d427b 100644 --- a/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/config/security/self/SelfAuthenticationProvider.java +++ b/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/config/security/self/SelfAuthenticationProvider.java @@ -1,17 +1,15 @@ package org.jeecg.config.security.self; -import com.alibaba.fastjson.JSONObject; import org.jeecg.common.api.CommonAPI; import org.jeecg.common.constant.CommonConstant; import org.jeecg.common.exception.JeecgBoot401Exception; import org.jeecg.common.exception.JeecgBootException; import org.jeecg.common.system.vo.LoginUser; -import org.jeecg.common.system.vo.SysDepartModel; import org.jeecg.common.util.RedisUtil; -import org.jeecg.common.util.oConvertUtils; import org.jeecg.config.JeecgBaseConfig; import org.jeecg.modules.base.service.BaseCommonService; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Lazy; import org.springframework.security.authentication.AuthenticationProvider; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.core.Authentication; @@ -48,6 +46,7 @@ public class SelfAuthenticationProvider implements AuthenticationProvider { private final OAuth2AuthorizationService authorizationService; private final OAuth2TokenGenerator tokenGenerator; + @Lazy @Autowired private CommonAPI commonAPI; @Autowired diff --git a/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/config/security/social/SocialGrantAuthenticationProvider.java b/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/config/security/social/SocialGrantAuthenticationProvider.java index 9349f4dca..74847827b 100644 --- a/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/config/security/social/SocialGrantAuthenticationProvider.java +++ b/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/config/security/social/SocialGrantAuthenticationProvider.java @@ -15,6 +15,7 @@ import org.jeecg.config.JeecgBaseConfig; import org.jeecg.config.security.password.PasswordGrantAuthenticationToken; import org.jeecg.modules.base.service.BaseCommonService; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Lazy; import org.springframework.security.authentication.AuthenticationProvider; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.core.Authentication; @@ -51,6 +52,7 @@ public class SocialGrantAuthenticationProvider implements AuthenticationProvider private final OAuth2AuthorizationService authorizationService; private final OAuth2TokenGenerator tokenGenerator; + @Lazy @Autowired private CommonAPI commonAPI; @Autowired