Merge remote-tracking branch 'origin/master'
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,8 +1,11 @@
|
||||
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;
|
||||
@ -12,7 +15,7 @@ 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 {
|
||||
|
||||
|
@ -15,8 +15,10 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.connection.RedisClusterConfiguration;
|
||||
import org.springframework.data.redis.connection.RedisNode;
|
||||
import org.springframework.data.redis.connection.RedisSentinelConfiguration;
|
||||
import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
|
||||
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
|
||||
import org.springframework.data.redis.core.RedisOperations;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
@ -69,10 +71,26 @@ public class RedisLettuceConfig {
|
||||
}
|
||||
|
||||
private LettuceConnectionFactory getLettuceConnectionFactory(Integer db) {
|
||||
LettuceConnectionFactory lettuceConnectionFactory = new LettuceConnectionFactory(this.sentinelConfig());
|
||||
lettuceConnectionFactory.setDatabase(db);
|
||||
lettuceConnectionFactory.afterPropertiesSet();
|
||||
return lettuceConnectionFactory;
|
||||
LettuceConnectionFactory factory;
|
||||
if (redisProperties.getCluster() != null && redisProperties.getCluster().getNodes() != null && !redisProperties.getCluster().getNodes().isEmpty()) {
|
||||
// 集群模式
|
||||
RedisClusterConfiguration clusterConfig = new RedisClusterConfiguration(redisProperties.getCluster().getNodes());
|
||||
clusterConfig.setPassword(redisProperties.getPassword());
|
||||
factory = new LettuceConnectionFactory(clusterConfig);
|
||||
} else if (redisProperties.getSentinel() != null && redisProperties.getSentinel().getNodes() != null && !redisProperties.getSentinel().getNodes().isEmpty()) {
|
||||
// 哨兵模式
|
||||
factory = new LettuceConnectionFactory(this.sentinelConfig());
|
||||
} else {
|
||||
// 单机模式
|
||||
RedisStandaloneConfiguration standaloneConfig = new RedisStandaloneConfiguration();
|
||||
standaloneConfig.setHostName(redisProperties.getHost());
|
||||
standaloneConfig.setPort(redisProperties.getPort());
|
||||
standaloneConfig.setPassword(redisProperties.getPassword());
|
||||
factory = new LettuceConnectionFactory(standaloneConfig);
|
||||
}
|
||||
factory.setDatabase(db);
|
||||
factory.afterPropertiesSet();
|
||||
return factory;
|
||||
}
|
||||
|
||||
private RedisSentinelConfiguration sentinelConfig() {
|
||||
|
@ -75,24 +75,6 @@ spring:
|
||||
sasl.mechanism: SCRAM-SHA-256
|
||||
sasl.jaas.config: org.apache.kafka.common.security.scram.ScramLoginModule required username="jltest" password="Unicom#123";
|
||||
|
||||
# 天宫 redis 需要使用哨兵进行访问
|
||||
redis:
|
||||
sentinel:
|
||||
master: eshop-redis
|
||||
nodes: 10.125.164.124:32718, 10.125.164.118:32716, 10.125.164.121:32716
|
||||
password: Unicom#135
|
||||
|
||||
# 天宫Eureka配置
|
||||
eureka:
|
||||
client:
|
||||
service-url:
|
||||
defaultZone: http://10.242.37.148:5001/eureka
|
||||
instance:
|
||||
prefer-ip-address: true
|
||||
ip-address: 125.32.114.204
|
||||
hostname: 125.32.114.204
|
||||
instance-ip: 125.32.114.204:${server.port}
|
||||
|
||||
mybatis-plus:
|
||||
configuration:
|
||||
# 是否开启自动驼峰命名规则映射:从数据库列名到Java属性驼峰命名的类似映射
|
||||
@ -123,6 +105,8 @@ hystrix:
|
||||
forceClosed: true
|
||||
|
||||
ribbon:
|
||||
eureka:
|
||||
enabled: false
|
||||
ReadTimeout: 20000 #请求处理的超时时间
|
||||
ConnectTimeout: 20000 #请求连接超时时间
|
||||
MaxAutoRetries: 0 #对当前实例的重试次数
|
||||
|
Reference in New Issue
Block a user