Selaa lähdekoodia

:sparkles: 添加新特性。在线令牌管理

冷冷 7 vuotta sitten
vanhempi
commit
ba23fd3b77
19 muutettua tiedostoa jossa 470 lisäystä ja 91 poistoa
  1. 2 0
      pigx-auth/src/main/java/com/pig4cloud/pigx/auth/config/WebSecurityConfigurer.java
  2. 181 0
      pigx-auth/src/main/java/com/pig4cloud/pigx/auth/endpoint/PigxTokenEndpoint.java
  3. 0 60
      pigx-auth/src/main/java/com/pig4cloud/pigx/auth/endpoint/RevokeTokenEndpoint.java
  4. 0 15
      pigx-common/pigx-common-log/src/main/java/com/pig4cloud/pigx/common/log/util/SysLogUtils.java
  5. 1 1
      pigx-config/src/main/resources/config/pigx-auth-dev.yml
  6. 1 1
      pigx-config/src/main/resources/config/pigx-codegen-dev.yml
  7. 1 1
      pigx-config/src/main/resources/config/pigx-daemon-dev.yml
  8. 1 1
      pigx-config/src/main/resources/config/pigx-upms-dev.yml
  9. 2 2
      pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/feign/RemoteLogService.java
  10. 54 0
      pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/feign/RemoteTokenService.java
  11. 38 0
      pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/feign/factory/RemoteLogServiceFallbackFactory.java
  12. 38 0
      pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/feign/factory/RemoteTokenServiceFallbackFactory.java
  13. 4 1
      pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/feign/fallback/RemoteLogServiceFallbackImpl.java
  14. 66 0
      pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/feign/fallback/RemoteTokenServiceFallbackImpl.java
  15. 4 1
      pigx-upms/pigx-upms-api/src/main/resources/META-INF/spring.factories
  16. 63 0
      pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/TokenController.java
  17. 8 5
      pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysUserMapper.java
  18. 5 2
      pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysUserService.java
  19. 1 1
      pigx-visual/pigx-tx-manager/src/main/java/com/pig4cloud/pigx/manager/compensate/service/impl/CompensateServiceImpl.java

+ 2 - 0
pigx-auth/src/main/java/com/pig4cloud/pigx/auth/config/WebSecurityConfigurer.java

@@ -64,6 +64,8 @@ public class WebSecurityConfigurer extends WebSecurityConfigurerAdapter {
 			.antMatchers(
 				"/actuator/**",
 				"/oauth/removeToken",
+				"/oauth/delToken/*",
+				"/oauth/listToken",
 				"/mobile/**").permitAll()
 			.anyRequest().authenticated()
 			.and().csrf().disable()

+ 181 - 0
pigx-auth/src/main/java/com/pig4cloud/pigx/auth/endpoint/PigxTokenEndpoint.java

@@ -0,0 +1,181 @@
+/*
+ *
+ *      Copyright (c) 2018-2025, lengleng All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the pig4cloud.com developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: lengleng (wangiegie@gmail.com)
+ *
+ */
+
+package com.pig4cloud.pigx.auth.endpoint;
+
+import cn.hutool.core.map.MapUtil;
+import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.plugins.Page;
+import com.pig4cloud.pigx.common.core.util.R;
+import com.pig4cloud.pigx.common.security.service.PigxUser;
+import lombok.AllArgsConstructor;
+import org.springframework.data.redis.core.ConvertingCursor;
+import org.springframework.data.redis.core.Cursor;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.core.ScanOptions;
+import org.springframework.data.redis.serializer.RedisSerializer;
+import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.oauth2.common.OAuth2AccessToken;
+import org.springframework.security.oauth2.provider.OAuth2Authentication;
+import org.springframework.security.oauth2.provider.token.TokenStore;
+import org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationToken;
+import org.springframework.util.StringUtils;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author lengleng
+ * @date 2018/6/24
+ * 删除token端点
+ */
+@RestController
+@AllArgsConstructor
+@RequestMapping("/oauth")
+public class PigxTokenEndpoint {
+	private static final String PIGX_OAUTH_ACCESS = "pigx_oauth:access:";
+	private final TokenStore tokenStore;
+	private final RedisTemplate redisTemplate;
+
+	/**
+	 * 退出token
+	 *
+	 * @param authHeader Authorization
+	 */
+	@GetMapping("/removeToken")
+	public R<Boolean> logout(@RequestHeader(value = "Authorization", required = false) String authHeader) {
+		if (StringUtils.hasText(authHeader)) {
+			String tokenValue = authHeader.replace("Bearer", "").trim();
+			OAuth2AccessToken accessToken = tokenStore.readAccessToken(tokenValue);
+			if (accessToken == null || StrUtil.isBlank(accessToken.getValue())) {
+				return new R<>(false, "退出失败,token 为空");
+			}
+			tokenStore.removeAccessToken(accessToken);
+		}
+
+		return new R<>(Boolean.TRUE);
+	}
+
+	/**
+	 * 令牌管理调用
+	 *
+	 * @param token token
+	 * @param from  内部调用标志
+	 * @return
+	 */
+	@DeleteMapping("/delToken/{token}")
+	public R<Boolean> delToken(@PathVariable("token") String token, @RequestHeader(required = false) String from) {
+		if (StrUtil.isBlank(from)) {
+			return null;
+		}
+		return new R<>(redisTemplate.delete(PIGX_OAUTH_ACCESS + token));
+	}
+
+
+	/**
+	 * 查询token
+	 *
+	 * @param params 分页参数
+	 * @param from   标志
+	 * @return
+	 */
+	@PostMapping("/listToken")
+	public Page tokenList(@RequestBody Map<String, Object> params, @RequestHeader(required = false) String from) {
+		if (StrUtil.isBlank(from)) {
+			return null;
+		}
+
+		List<Map<String, String>> list = new ArrayList<>();
+		//根据分页参数获取对应数据
+		List<String> pages = findKeysForPage(PIGX_OAUTH_ACCESS + "*", MapUtil.getInt(params, "page"), MapUtil.getInt(params, "limit"));
+
+		for (String page : pages) {
+			String accessToken = StrUtil.subAfter(page, PIGX_OAUTH_ACCESS, true);
+			OAuth2AccessToken token = tokenStore.readAccessToken(accessToken);
+			Map<String, String> map = new HashMap<>(8);
+
+
+			map.put("token_type", token.getTokenType());
+			map.put("token_value", token.getValue());
+			map.put("expires_in", token.getExpiresIn() + "");
+
+
+			OAuth2Authentication oAuth2Auth = tokenStore.readAuthentication(token);
+			Authentication authentication = oAuth2Auth.getUserAuthentication();
+
+			map.put("client_id", oAuth2Auth.getOAuth2Request().getClientId());
+			map.put("grant_type", oAuth2Auth.getOAuth2Request().getGrantType());
+
+			if (authentication instanceof UsernamePasswordAuthenticationToken) {
+				UsernamePasswordAuthenticationToken authenticationToken = (UsernamePasswordAuthenticationToken) authentication;
+
+				if (authenticationToken.getPrincipal() instanceof PigxUser) {
+					PigxUser user = (PigxUser) authenticationToken.getPrincipal();
+					map.put("user_id", user.getId() + "");
+					map.put("user_name", user.getUsername() + "");
+				}
+			} else if (authentication instanceof PreAuthenticatedAuthenticationToken) {
+				//刷新token方式
+				PreAuthenticatedAuthenticationToken authenticationToken = (PreAuthenticatedAuthenticationToken) authentication;
+				if (authenticationToken.getPrincipal() instanceof PigxUser) {
+					PigxUser user = (PigxUser) authenticationToken.getPrincipal();
+					map.put("user_id", user.getId() + "");
+					map.put("user_name", user.getUsername() + "");
+				}
+			}
+			list.add(map);
+		}
+
+		Page result = new Page(MapUtil.getInt(params, "page"), MapUtil.getInt(params, "limit"));
+		result.setRecords(list);
+		result.setTotal(redisTemplate.keys(PIGX_OAUTH_ACCESS + "*").size());
+		return result;
+	}
+
+	private List<String> findKeysForPage(String patternKey, int pageNum, int pageSize) {
+		ScanOptions options = ScanOptions.scanOptions().match(patternKey).build();
+		RedisSerializer<String> redisSerializer = (RedisSerializer<String>) redisTemplate.getKeySerializer();
+		Cursor cursor = (Cursor) redisTemplate.executeWithStickyConnection(redisConnection -> {
+			return new ConvertingCursor<>(redisConnection.scan(options), redisSerializer::deserialize);
+		});
+		List<String> result = new ArrayList<>();
+		int tmpIndex = 0;
+		int startIndex = (pageNum - 1) * pageSize;
+		int end = pageNum * pageSize;
+
+		assert cursor != null;
+		while (cursor.hasNext()) {
+			if (tmpIndex >= startIndex && tmpIndex < end) {
+				result.add(cursor.next().toString());
+				tmpIndex++;
+				continue;
+			}
+			if (tmpIndex >= end) {
+				break;
+			}
+			tmpIndex++;
+			cursor.next();
+		}
+		return result;
+	}
+}

+ 0 - 60
pigx-auth/src/main/java/com/pig4cloud/pigx/auth/endpoint/RevokeTokenEndpoint.java

@@ -1,60 +0,0 @@
-/*
- *
- *      Copyright (c) 2018-2025, lengleng All rights reserved.
- *
- *  Redistribution and use in source and binary forms, with or without
- *  modification, are permitted provided that the following conditions are met:
- *
- * Redistributions of source code must retain the above copyright notice,
- *  this list of conditions and the following disclaimer.
- *  Redistributions in binary form must reproduce the above copyright
- *  notice, this list of conditions and the following disclaimer in the
- *  documentation and/or other materials provided with the distribution.
- *  Neither the name of the pig4cloud.com developer nor the names of its
- *  contributors may be used to endorse or promote products derived from
- *  this software without specific prior written permission.
- *  Author: lengleng (wangiegie@gmail.com)
- *
- */
-
-package com.pig4cloud.pigx.auth.endpoint;
-
-import cn.hutool.core.util.StrUtil;
-import com.pig4cloud.pigx.common.core.util.R;
-import lombok.AllArgsConstructor;
-import org.springframework.security.oauth2.common.OAuth2AccessToken;
-import org.springframework.security.oauth2.provider.token.TokenStore;
-import org.springframework.util.StringUtils;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestHeader;
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- * @author lengleng
- * @date 2018/6/24
- * 删除token端点
- */
-@RestController
-@AllArgsConstructor
-public class RevokeTokenEndpoint {
-	private final TokenStore tokenStore;
-
-	/**
-	 * 删除token
-	 *
-	 * @param authHeader Authorization
-	 */
-	@GetMapping("/oauth/removeToken")
-	public R<Boolean> logout(@RequestHeader(value = "Authorization", required = false) String authHeader) {
-		if (StringUtils.hasText(authHeader)) {
-			String tokenValue = authHeader.replace("Bearer", "").trim();
-			OAuth2AccessToken accessToken = tokenStore.readAccessToken(tokenValue);
-			if (accessToken == null || StrUtil.isBlank(accessToken.getValue())) {
-				return new R<>(false, "退出失败,token 为空");
-			}
-			tokenStore.removeAccessToken(accessToken);
-		}
-
-		return new R<>(Boolean.TRUE);
-	}
-}

+ 0 - 15
pigx-common/pigx-common-log/src/main/java/com/pig4cloud/pigx/common/log/util/SysLogUtils.java

@@ -19,7 +19,6 @@
 
 package com.pig4cloud.pigx.common.log.util;
 
-import cn.hutool.core.util.ArrayUtil;
 import cn.hutool.core.util.URLUtil;
 import cn.hutool.http.HttpUtil;
 import com.pig4cloud.pigx.admin.api.entity.SysLog;
@@ -36,22 +35,8 @@ import javax.servlet.http.HttpServletRequest;
  * @author L.cm
  */
 public class SysLogUtils {
-
-	private static final String PASSWORD = "password";
-
 	public static SysLog getSysLog() {
 		HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
-		StringBuilder params = new StringBuilder();
-		request.getParameterMap().forEach((key, values) -> {
-			params.append(key).append("=");
-			if (PASSWORD.equalsIgnoreCase(key)) {
-				params.append("******");
-			} else {
-				params.append(ArrayUtil.toString(values));
-			}
-			params.append("&");
-		});
-
 		SysLog sysLog = new SysLog();
 		sysLog.setCreateBy(SecurityUtils.getUser().getUsername());
 		sysLog.setType(CommonConstant.STATUS_NORMAL);

+ 1 - 1
pigx-config/src/main/resources/config/pigx-auth-dev.yml

@@ -5,4 +5,4 @@ spring:
     driver-class-name: com.mysql.jdbc.Driver
     username: root
     password:  Bjyjht2017!@#
-    url: jdbc:mysql://114.116.30.176:3306/pigx?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false
+    url: jdbc:mysql://114.116.21.191:3306/pigx?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false

+ 1 - 1
pigx-config/src/main/resources/config/pigx-codegen-dev.yml

@@ -13,7 +13,7 @@ spring:
     driver-class-name: com.mysql.jdbc.Driver
     username: root
     password:  Bjyjht2017!@#
-    url: jdbc:mysql://114.116.30.176:3306/pigx?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false
+    url: jdbc:mysql://114.116.21.191:3306/pigx?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false
   jackson:
     time-zone: GMT+8
     date-format: yyyy-MM-dd HH:mm:ss

+ 1 - 1
pigx-config/src/main/resources/config/pigx-daemon-dev.yml

@@ -14,7 +14,7 @@ spring:
     driver-class-name: com.mysql.jdbc.Driver
     username: root
     password:  Bjyjht2017!@#
-    url: jdbc:mysql://114.116.30.176:3306/pigx?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false
+    url: jdbc:mysql://114.116.21.191:3306/pigx?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false
   elasticjob:
     # 分布式任务协调依赖zookeeper
     zookeeper:

+ 1 - 1
pigx-config/src/main/resources/config/pigx-upms-dev.yml

@@ -13,7 +13,7 @@ spring:
     driver-class-name: com.mysql.jdbc.Driver
     username: root
     password:  Bjyjht2017!@#
-    url: jdbc:mysql://114.116.30.176:3306/pigx?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false
+    url: jdbc:mysql://114.116.21.191:3306/pigx?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false
 
 # mybaits 模块配置
 mybatis-plus:

+ 2 - 2
pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/feign/RemoteLogService.java

@@ -20,7 +20,7 @@
 package com.pig4cloud.pigx.admin.api.feign;
 
 import com.pig4cloud.pigx.admin.api.entity.SysLog;
-import com.pig4cloud.pigx.admin.api.feign.fallback.RemoteLogServiceFallbackImpl;
+import com.pig4cloud.pigx.admin.api.feign.factory.RemoteLogServiceFallbackFactory;
 import com.pig4cloud.pigx.common.core.constant.ServiceNameConstant;
 import com.pig4cloud.pigx.common.core.util.R;
 import org.springframework.cloud.openfeign.FeignClient;
@@ -31,7 +31,7 @@ import org.springframework.web.bind.annotation.RequestBody;
  * @author lengleng
  * @date 2018/6/28
  */
-@FeignClient(value = ServiceNameConstant.UMPS_SERVICE, fallback = RemoteLogServiceFallbackImpl.class)
+@FeignClient(value = ServiceNameConstant.UMPS_SERVICE, fallbackFactory = RemoteLogServiceFallbackFactory.class)
 public interface RemoteLogService {
 	/**
 	 * 保存日志

+ 54 - 0
pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/feign/RemoteTokenService.java

@@ -0,0 +1,54 @@
+/*
+ *    Copyright (c) 2018-2025, lengleng All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the pig4cloud.com developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: lengleng (wangiegie@gmail.com)
+ */
+
+package com.pig4cloud.pigx.admin.api.feign;
+
+import com.baomidou.mybatisplus.plugins.Page;
+import com.pig4cloud.pigx.admin.api.feign.factory.RemoteTokenServiceFallbackFactory;
+import com.pig4cloud.pigx.common.core.constant.ServiceNameConstant;
+import com.pig4cloud.pigx.common.core.util.R;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.Map;
+
+/**
+ * @author lengleng
+ * @date 2018/9/4
+ */
+@FeignClient(value = ServiceNameConstant.AUTH_SERVICE, fallbackFactory = RemoteTokenServiceFallbackFactory.class)
+public interface RemoteTokenService {
+	/**
+	 * 分页查询token 信息
+	 *
+	 * @param params 分页参数
+	 * @param from   内部调用标志
+	 * @return page
+	 */
+	@PostMapping("/oauth/listToken")
+	Page selectPage(@RequestBody Map<String, Object> params, @RequestHeader("from") String from);
+
+	/**
+	 * 删除token
+	 *
+	 * @param token token
+	 * @param from  调用标志
+	 * @return
+	 */
+	@DeleteMapping("/oauth/delToken/{token}")
+	R<Boolean> deleteTokenById(@PathVariable("token") String token, @RequestHeader("from") String from);
+}

+ 38 - 0
pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/feign/factory/RemoteLogServiceFallbackFactory.java

@@ -0,0 +1,38 @@
+/*
+ *    Copyright (c) 2018-2025, lengleng All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the pig4cloud.com developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: lengleng (wangiegie@gmail.com)
+ */
+
+package com.pig4cloud.pigx.admin.api.feign.factory;
+
+import com.pig4cloud.pigx.admin.api.feign.RemoteLogService;
+import com.pig4cloud.pigx.admin.api.feign.fallback.RemoteLogServiceFallbackImpl;
+import feign.hystrix.FallbackFactory;
+import org.springframework.stereotype.Component;
+
+/**
+ * @author lengleng
+ * @date 2018/9/4
+ */
+@Component
+public class RemoteLogServiceFallbackFactory implements FallbackFactory<RemoteLogService> {
+
+	@Override
+	public RemoteLogService create(Throwable throwable) {
+		RemoteLogServiceFallbackImpl remoteLogServiceFallback = new RemoteLogServiceFallbackImpl();
+		remoteLogServiceFallback.setCause(throwable);
+		return remoteLogServiceFallback;
+	}
+}

+ 38 - 0
pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/feign/factory/RemoteTokenServiceFallbackFactory.java

@@ -0,0 +1,38 @@
+/*
+ *    Copyright (c) 2018-2025, lengleng All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the pig4cloud.com developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: lengleng (wangiegie@gmail.com)
+ */
+
+package com.pig4cloud.pigx.admin.api.feign.factory;
+
+import com.pig4cloud.pigx.admin.api.feign.RemoteTokenService;
+import com.pig4cloud.pigx.admin.api.feign.fallback.RemoteTokenServiceFallbackImpl;
+import feign.hystrix.FallbackFactory;
+import org.springframework.stereotype.Component;
+
+/**
+ * @author lengleng
+ * @date 2018/9/4
+ */
+@Component
+public class RemoteTokenServiceFallbackFactory implements FallbackFactory<RemoteTokenService> {
+
+	@Override
+	public RemoteTokenService create(Throwable throwable) {
+		RemoteTokenServiceFallbackImpl remoteTokenServiceFallback = new RemoteTokenServiceFallbackImpl();
+		remoteTokenServiceFallback.setCause(throwable);
+		return remoteTokenServiceFallback;
+	}
+}

+ 4 - 1
pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/feign/fallback/RemoteLogServiceFallbackImpl.java

@@ -22,6 +22,7 @@ package com.pig4cloud.pigx.admin.api.feign.fallback;
 import com.pig4cloud.pigx.admin.api.entity.SysLog;
 import com.pig4cloud.pigx.admin.api.feign.RemoteLogService;
 import com.pig4cloud.pigx.common.core.util.R;
+import lombok.Setter;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Component;
 
@@ -32,6 +33,8 @@ import org.springframework.stereotype.Component;
 @Slf4j
 @Component
 public class RemoteLogServiceFallbackImpl implements RemoteLogService {
+	@Setter
+	private Throwable cause;
 
 	/**
 	 * 保存日志
@@ -41,7 +44,7 @@ public class RemoteLogServiceFallbackImpl implements RemoteLogService {
 	 */
 	@Override
 	public R<Boolean> saveLog(SysLog sysLog) {
-		log.error("feign 插入日志失败:{}");
+		log.error("feign 插入日志失败", cause);
 		return null;
 	}
 }

+ 66 - 0
pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/feign/fallback/RemoteTokenServiceFallbackImpl.java

@@ -0,0 +1,66 @@
+/*
+ *    Copyright (c) 2018-2025, lengleng All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the pig4cloud.com developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: lengleng (wangiegie@gmail.com)
+ */
+
+package com.pig4cloud.pigx.admin.api.feign.fallback;
+
+import com.baomidou.mybatisplus.plugins.Page;
+import com.pig4cloud.pigx.admin.api.feign.RemoteTokenService;
+import com.pig4cloud.pigx.common.core.util.R;
+import lombok.Setter;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+
+import java.util.Map;
+
+/**
+ * @author lengleng
+ * @date 2018/9/4
+ * feign token  fallback
+ */
+@Slf4j
+@Component
+public class RemoteTokenServiceFallbackImpl implements RemoteTokenService {
+	@Setter
+	private Throwable cause;
+
+	/**
+	 * 分页查询token 信息
+	 *
+	 * @param params 分页参数
+	 * @param from   内部调用标志
+	 * @return page
+	 */
+	@Override
+	public Page selectPage(Map<String, Object> params, String from) {
+		log.error("调用认证中心查询token 失败", cause);
+		return null;
+	}
+
+	/**
+	 * 删除token
+	 *
+	 *
+	 * @param s
+	 * @param id
+	 * @return
+	 */
+	@Override
+	public R<Boolean> deleteTokenById(String s, String id) {
+		log.error("删除token 失败 {}", id, cause);
+		return null;
+	}
+}

+ 4 - 1
pigx-upms/pigx-upms-api/src/main/resources/META-INF/spring.factories

@@ -1,4 +1,7 @@
 org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
   com.pig4cloud.pigx.admin.api.feign.fallback.RemoteUserServiceFallbackImpl,\
   com.pig4cloud.pigx.admin.api.feign.fallback.RemoteLogServiceFallbackImpl,\
-  com.pig4cloud.pigx.admin.api.feign.factory.RemoteUserServiceFallbackFactory
+  com.pig4cloud.pigx.admin.api.feign.fallback.RemoteTokenServiceFallbackImpl,\
+  com.pig4cloud.pigx.admin.api.feign.factory.RemoteUserServiceFallbackFactory,\
+  com.pig4cloud.pigx.admin.api.feign.factory.RemoteLogServiceFallbackFactory,\
+  com.pig4cloud.pigx.admin.api.feign.factory.RemoteTokenServiceFallbackFactory

+ 63 - 0
pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/TokenController.java

@@ -0,0 +1,63 @@
+/*
+ *    Copyright (c) 2018-2025, lengleng All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the pig4cloud.com developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: lengleng (wangiegie@gmail.com)
+ */
+
+package com.pig4cloud.pigx.admin.controller;
+
+import com.baomidou.mybatisplus.plugins.Page;
+import com.pig4cloud.pigx.admin.api.feign.RemoteTokenService;
+import com.pig4cloud.pigx.common.core.constant.SecurityConstants;
+import com.pig4cloud.pigx.common.core.util.R;
+import lombok.AllArgsConstructor;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.Map;
+
+/**
+ * @author lengleng
+ * @date 2018/9/4
+ * token 管理
+ */
+@RestController
+@AllArgsConstructor
+@RequestMapping("/token")
+public class TokenController {
+	private final RemoteTokenService remoteTokenService;
+
+	/**
+	 * 分页token 信息
+	 *
+	 * @param params 参数集
+	 * @return token集合
+	 */
+	@GetMapping("/page")
+	public Page token(@RequestParam Map<String, Object> params) {
+		return remoteTokenService.selectPage(params, SecurityConstants.FROM_IN);
+	}
+
+	/**
+	 * 删除
+	 *
+	 * @param id ID
+	 * @return success/false
+	 */
+	@DeleteMapping("/{id}")
+	@PreAuthorize("@pms.hasPermission('sys_token_del')")
+	public R<Boolean> delete(@PathVariable String id) {
+		return remoteTokenService.deleteTokenById(id, SecurityConstants.FROM_IN);
+	}
+}

+ 8 - 5
pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysUserMapper.java

@@ -48,8 +48,8 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
 	/**
 	 * 分页查询用户信息(含角色)
 	 *
-	 * @param query    查询条件
-	 * @param username 用户名
+	 * @param query     查询条件
+	 * @param username  用户名
 	 * @param dataScope
 	 * @return list
 	 */
@@ -65,16 +65,19 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
 
 	/**
 	 * 通过用户名查找已经删除的用户
+	 *
 	 * @param username 用户名
 	 * @return 用户对象
 	 */
-	SysUser selectDeletedUserByUsername(@Param("username")String username);
+	SysUser selectDeletedUserByUsername(@Param("username") String username);
 
 	/**
 	 * 根据用户名删除用户(真实删除)
-	 * @param username
+	 *
+	 * @param username username
+	 * @param userId   userId
 	 * @return
 	 */
-	Boolean deleteSysUserByUsernameAndUserId(@Param("username")String username,@Param("userId")Integer userId);
+	Boolean deleteSysUserByUsernameAndUserId(@Param("username") String username, @Param("userId") Integer userId);
 
 }

+ 5 - 2
pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysUserService.java

@@ -87,6 +87,7 @@ public interface SysUserService extends IService<SysUser> {
 
 	/**
 	 * 通过用户名查找已经删除的用户
+	 *
 	 * @param username 用户名
 	 * @return
 	 */
@@ -94,10 +95,12 @@ public interface SysUserService extends IService<SysUser> {
 
 	/**
 	 * 根据用户名删除用户(真实删除)
-	 * @param username
+	 *
+	 * @param username username
+	 * @param userId   userId
 	 * @return
 	 */
-	Boolean deleteSysUserByUsernameAndUserId(String username,Integer userId);
+	Boolean deleteSysUserByUsernameAndUserId(String username, Integer userId);
 
 
 }

+ 1 - 1
pigx-visual/pigx-tx-manager/src/main/java/com/pig4cloud/pigx/manager/compensate/service/impl/CompensateServiceImpl.java

@@ -131,7 +131,7 @@ public class CompensateServiceImpl implements CompensateService {
 		logger.info("Auto Compensate->" + json);
 		//自动补偿业务执行...
 		final int tryTime = configReader.getCompensateTryTime();
-		boolean autoExecuteRes = false;
+		boolean autoExecuteRes;
 		try {
 			int executeCount = 0;
 			autoExecuteRes = executeCompensate_(json);