修改代码
This commit is contained in:
@ -8,7 +8,6 @@ import com.chinaunicom.mall.ebtp.cloud.security.starter.entity.AuthAllows;
|
||||
import com.chinaunicom.mall.ebtp.cloud.security.starter.entity.ExternalAllows;
|
||||
import com.chinaunicom.mall.ebtp.cloud.security.starter.entity.RoleCodeAuthority;
|
||||
import com.chinaunicom.mall.ebtp.cloud.security.starter.entity.SecurityUser;
|
||||
import com.chinaunicom.mall.ebtp.cloud.userinfo.starter.client.EbtpUserInfoClient;
|
||||
import com.chinaunicom.mall.ebtp.cloud.userinfo.starter.entity.CheckTokenVo;
|
||||
import com.chinaunicom.mall.ebtp.cloud.userinfo.starter.service.UserInfoService;
|
||||
import com.chinaunicom.mall.ebtp.common.base.entity.BaseCacheUser;
|
||||
@ -45,7 +44,7 @@ import static com.chinaunicom.mall.ebtp.cloud.security.starter.common.Constants.
|
||||
* @author Ajaxfan
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
//@Component
|
||||
public class TokenAuthenticationFilter extends OncePerRequestFilter {
|
||||
@Autowired
|
||||
private UserInfoService client;
|
||||
@ -55,9 +54,6 @@ public class TokenAuthenticationFilter extends OncePerRequestFilter {
|
||||
@Autowired
|
||||
private ExternalAllows eAllows;
|
||||
|
||||
@Autowired
|
||||
private EbtpUserInfoClient ebtpClient;
|
||||
|
||||
@Autowired(required = false)
|
||||
@Qualifier("userinfoRedisTemplate")
|
||||
private RedisTemplate<String, Object> redisTemplate;
|
||||
|
@ -17,9 +17,9 @@ import org.springframework.web.client.RestTemplate;
|
||||
@ComponentScan(basePackages = "com.chinaunicom.mall.ebtp.cloud.userinfo.starter")
|
||||
public class UserinfoStarterConfiguration {
|
||||
|
||||
@Bean
|
||||
public RestTemplate restTemplate() {
|
||||
return new RestTemplate();
|
||||
}
|
||||
// @Bean
|
||||
// public RestTemplate restTemplate() {
|
||||
// return new RestTemplate();
|
||||
// }
|
||||
|
||||
}
|
||||
|
@ -1,35 +0,0 @@
|
||||
package com.chinaunicom.mall.ebtp.cloud.userinfo.starter.client;
|
||||
|
||||
import com.chinaunicom.mall.ebtp.cloud.userinfo.starter.entity.CheckTokenVo;
|
||||
import com.chinaunicom.mall.ebtp.cloud.userinfo.starter.fallback.EbtpUserInfoClientFallbackFactory;
|
||||
import com.chinaunicom.mall.ebtp.common.base.entity.BaseResponse;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
/**
|
||||
* 文档中心数据服务客户端
|
||||
*
|
||||
* @author Ajaxfan
|
||||
*/
|
||||
@FeignClient(value = "sys-manager-ebtp-project")
|
||||
public interface EbtpUserInfoClient {
|
||||
|
||||
/**
|
||||
* 刷新redis缓存的信息
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/v1/userinfo/refresh")
|
||||
public ResponseEntity<Boolean> refreshToken();
|
||||
|
||||
/**
|
||||
* 获取配置信息
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/v1/checkToken/getCheckTokenVo")
|
||||
public BaseResponse<CheckTokenVo> getCheckTokenVo(@RequestParam("ps") String ps);
|
||||
}
|
@ -1,18 +1,21 @@
|
||||
package com.chinaunicom.mall.ebtp.cloud.userinfo.starter.client;
|
||||
|
||||
import com.chinaunicom.mall.ebtp.cloud.security.starter.entity.SecurityEntity;
|
||||
import com.chinaunicom.mall.ebtp.cloud.userinfo.starter.entity.CheckTokenVo;
|
||||
import com.chinaunicom.mall.ebtp.cloud.userinfo.starter.fallback.UnifastOAuthClientFallbackFactory;
|
||||
import com.chinaunicom.mall.ebtp.common.base.entity.BaseResponse;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
/**
|
||||
* 文档中心数据服务客户端
|
||||
*
|
||||
*
|
||||
* @author Ajaxfan
|
||||
*/
|
||||
@FeignClient(value = "${user.auth.resource.serviceId:sys-manager-ebtp-project}",
|
||||
@FeignClient(value = "sys-manager-ebtp-project",
|
||||
fallbackFactory = UnifastOAuthClientFallbackFactory.class)
|
||||
public interface UnifastOAuthClient {
|
||||
|
||||
@ -22,4 +25,19 @@ public interface UnifastOAuthClient {
|
||||
@PostMapping("/v1/userinfo/oauth/check_token")
|
||||
SecurityEntity getPost(@RequestParam("token") String token);
|
||||
|
||||
/**
|
||||
* 刷新redis缓存的信息
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/v1/userinfo/refresh")
|
||||
public ResponseEntity<Boolean> refreshToken();
|
||||
|
||||
/**
|
||||
* 获取配置信息
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/v1/checkToken/getCheckTokenVo")
|
||||
public BaseResponse<CheckTokenVo> getCheckTokenVo(@RequestParam("ps") String ps);
|
||||
|
||||
}
|
||||
|
@ -1,22 +0,0 @@
|
||||
package com.chinaunicom.mall.ebtp.cloud.userinfo.starter.fallback;
|
||||
|
||||
import com.chinaunicom.mall.ebtp.cloud.userinfo.starter.client.EbtpUserInfoClient;
|
||||
import com.chinaunicom.mall.ebtp.cloud.userinfo.starter.entity.CheckTokenVo;
|
||||
import com.chinaunicom.mall.ebtp.common.base.entity.BaseResponse;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class EbtpUserInfoClientFallback implements EbtpUserInfoClient {
|
||||
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Boolean> refreshToken() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseResponse<CheckTokenVo> getCheckTokenVo(String ps) {
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
package com.chinaunicom.mall.ebtp.cloud.userinfo.starter.fallback;
|
||||
|
||||
import com.chinaunicom.mall.ebtp.cloud.security.starter.entity.SecurityEntity;
|
||||
import com.chinaunicom.mall.ebtp.cloud.userinfo.starter.client.EbtpUserInfoClient;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class EbtpUserInfoClientFallbackFactory implements FallbackFactory<EbtpUserInfoClient> {
|
||||
@Override
|
||||
public EbtpUserInfoClient create(Throwable throwable) {
|
||||
log.error("EbtpUserInfoClient error : " + throwable.getMessage());
|
||||
return new EbtpUserInfoClientFallback();
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public EbtpUserInfoClient create(Throwable throwable) {
|
||||
// log.error("EbtpUserInfoClient error : " + throwable.getMessage());
|
||||
// return () -> ResponseEntity.ok(null);
|
||||
// }
|
||||
|
||||
}
|
@ -2,6 +2,9 @@ package com.chinaunicom.mall.ebtp.cloud.userinfo.starter.fallback;
|
||||
|
||||
import com.chinaunicom.mall.ebtp.cloud.security.starter.entity.SecurityEntity;
|
||||
import com.chinaunicom.mall.ebtp.cloud.userinfo.starter.client.UnifastOAuthClient;
|
||||
import com.chinaunicom.mall.ebtp.cloud.userinfo.starter.entity.CheckTokenVo;
|
||||
import com.chinaunicom.mall.ebtp.common.base.entity.BaseResponse;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@ -17,4 +20,14 @@ public class UnifastOAuthClientFallback implements UnifastOAuthClient {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Boolean> refreshToken() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseResponse<CheckTokenVo> getCheckTokenVo(String ps) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -22,7 +22,6 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import com.chinaunicom.mall.ebtp.cloud.security.starter.entity.AuthorityEntity;
|
||||
import com.chinaunicom.mall.ebtp.cloud.security.starter.entity.SecurityEntity;
|
||||
import com.chinaunicom.mall.ebtp.cloud.userinfo.starter.client.EbtpUserInfoClient;
|
||||
import com.chinaunicom.mall.ebtp.cloud.userinfo.starter.client.UnifastOAuthClient;
|
||||
import com.chinaunicom.mall.ebtp.cloud.userinfo.starter.entity.CheckTokenVo;
|
||||
import com.chinaunicom.mall.ebtp.cloud.userinfo.starter.service.UserInfoService;
|
||||
@ -44,9 +43,6 @@ private Integer valid_time_limit;
|
||||
@Qualifier("userinfoRedisTemplate")
|
||||
private RedisTemplate<String, Object> redisTemplate;
|
||||
|
||||
@Autowired
|
||||
private EbtpUserInfoClient ebtpClient;
|
||||
|
||||
@Override
|
||||
public BaseCacheUser getUserInfo(String token) {
|
||||
token = token.replaceAll(TOKEN_PREFIX, "");
|
||||
@ -213,7 +209,7 @@ private Integer valid_time_limit;
|
||||
if (o != null) {
|
||||
return (CheckTokenVo)o;
|
||||
}else{
|
||||
BaseResponse<CheckTokenVo> baseResponse = ebtpClient.getCheckTokenVo("eshop@2024");
|
||||
BaseResponse<CheckTokenVo> baseResponse = client.getCheckTokenVo("eshop@2024");
|
||||
//log.info("responseEntity:" + baseResponse);
|
||||
if (baseResponse.getData() != null) {
|
||||
//log.info("responseEntity.getBody():" + baseResponse.getData());
|
||||
|
@ -4,6 +4,7 @@ import com.chinaunicom.mall.ebtp.common.util.JsonUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.annotation.AsyncConfigurer;
|
||||
@ -21,6 +22,7 @@ import java.util.concurrent.Executor;
|
||||
@Configuration
|
||||
@EnableAsync
|
||||
@EnableConfigurationProperties(AsyncProperties.class)
|
||||
@ConditionalOnProperty(prefix = "async.thead.pool", name = "core-size", matchIfMissing = false)
|
||||
@Slf4j
|
||||
public class AsyncConfig implements AsyncConfigurer {
|
||||
|
||||
|
Reference in New Issue
Block a user