Browse Source

no message

BF-202308171519\Administrator 2 years ago
parent
commit
3abdf747cb

+ 0 - 1
kxs-codegen/src/main/java/com/kxs/codegen/biz/KxsCodeGenApplication.java

@@ -14,7 +14,6 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
  */
  */
 @EnableDynamicDataSource
 @EnableDynamicDataSource
 @EnableAuthResourceServer
 @EnableAuthResourceServer
-@EnableLoginResourceServer
 @SpringBootApplication
 @SpringBootApplication
 public class KxsCodeGenApplication {
 public class KxsCodeGenApplication {
 
 

+ 2 - 1
kxs-common/kxs-common-core/src/main/java/com/kxs/common/core/exception/GlobalBizExceptionHandler.java

@@ -26,7 +26,7 @@ import java.util.List;
  */
  */
 @Slf4j
 @Slf4j
 @RestControllerAdvice
 @RestControllerAdvice
-@Order(Integer.MIN_VALUE)
+@Order(10000)
 public class GlobalBizExceptionHandler {
 public class GlobalBizExceptionHandler {
 
 
     /**
     /**
@@ -41,6 +41,7 @@ public class GlobalBizExceptionHandler {
 
 
         return R.failed(e.getLocalizedMessage());
         return R.failed(e.getLocalizedMessage());
     }
     }
+
     /**
     /**
      * 运行时异常.
      * 运行时异常.
      * @param e the e
      * @param e the e

+ 7 - 14
kxs-common/kxs-common-security/src/main/java/com/kxs/common/security/component/SkyCustomOpaqueTokenIntrospector.java

@@ -1,15 +1,13 @@
 package com.kxs.common.security.component;
 package com.kxs.common.security.component;
 
 
 import cn.hutool.extra.spring.SpringUtil;
 import cn.hutool.extra.spring.SpringUtil;
-import com.kxs.common.core.constant.SecurityConstants;
 import com.kxs.common.security.model.KxsUser;
 import com.kxs.common.security.model.KxsUser;
 import com.kxs.common.security.service.KxsUserDetailsService;
 import com.kxs.common.security.service.KxsUserDetailsService;
 import lombok.RequiredArgsConstructor;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.core.Ordered;
 import org.springframework.core.Ordered;
-import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
+import org.springframework.security.core.Authentication;
 import org.springframework.security.core.authority.AuthorityUtils;
 import org.springframework.security.core.authority.AuthorityUtils;
-import org.springframework.security.core.userdetails.UserDetails;
 import org.springframework.security.core.userdetails.UsernameNotFoundException;
 import org.springframework.security.core.userdetails.UsernameNotFoundException;
 import org.springframework.security.oauth2.core.AuthorizationGrantType;
 import org.springframework.security.oauth2.core.AuthorizationGrantType;
 import org.springframework.security.oauth2.core.OAuth2AuthenticatedPrincipal;
 import org.springframework.security.oauth2.core.OAuth2AuthenticatedPrincipal;
@@ -57,12 +55,13 @@ public class SkyCustomOpaqueTokenIntrospector implements OpaqueTokenIntrospector
 					oldAuthorization.getAuthorizationGrantType().getValue()))
 					oldAuthorization.getAuthorizationGrantType().getValue()))
 			.max(Comparator.comparingInt(Ordered::getOrder));
 			.max(Comparator.comparingInt(Ordered::getOrder));
 
 
-		UserDetails userDetails = null;
 		try {
 		try {
+
+			//获取用户信息
 			Object principal = Objects.requireNonNull(oldAuthorization).getAttributes().get(Principal.class.getName());
 			Object principal = Objects.requireNonNull(oldAuthorization).getAttributes().get(Principal.class.getName());
-			UsernamePasswordAuthenticationToken usernamePasswordAuthenticationToken = (UsernamePasswordAuthenticationToken) principal;
-			Object tokenPrincipal = usernamePasswordAuthenticationToken.getPrincipal();
-			userDetails = optional.get().loadUserByUser((KxsUser) tokenPrincipal);
+			Authentication authentication = (Authentication) principal;
+
+			return (KxsUser) authentication.getPrincipal();
 		}
 		}
 		catch (UsernameNotFoundException notFoundException) {
 		catch (UsernameNotFoundException notFoundException) {
 			log.warn("用户不不存在 {}", notFoundException.getLocalizedMessage());
 			log.warn("用户不不存在 {}", notFoundException.getLocalizedMessage());
@@ -70,14 +69,8 @@ public class SkyCustomOpaqueTokenIntrospector implements OpaqueTokenIntrospector
 		}
 		}
 		catch (Exception ex) {
 		catch (Exception ex) {
 			log.error("资源服务器 introspect Token error {}", ex.getLocalizedMessage());
 			log.error("资源服务器 introspect Token error {}", ex.getLocalizedMessage());
+			throw new RuntimeException(ex);
 		}
 		}
-
-		// 注入客户端信息,方便上下文中获取
-		KxsUser kxsUser = (KxsUser) userDetails;
-		Objects.requireNonNull(kxsUser)
-			.getAttributes()
-			.put(SecurityConstants.CLIENT_ID, oldAuthorization.getRegisteredClientId());
-		return kxsUser;
 	}
 	}
 
 
 }
 }

+ 1 - 0
kxs-system/kxs-system-biz/src/main/java/com/kxs/system/biz/controller/SysUserController.java

@@ -140,6 +140,7 @@ public class SysUserController {
 	 */
 	 */
 	@GetMapping("/page")
 	@GetMapping("/page")
 	public R getUserPage(@ParameterObject Page page, @ParameterObject UserDTO userDTO) {
 	public R getUserPage(@ParameterObject Page page, @ParameterObject UserDTO userDTO) {
+		int i = 10/0;
 		return R.ok(userService.getUsersWithRolePage(page, userDTO));
 		return R.ok(userService.getUsersWithRolePage(page, userDTO));
 	}
 	}