diff --git a/pig-gateway/src/main/java/com/pig4cloud/pig/gateway/config/GatewayConfiguration.java b/pig-gateway/src/main/java/com/pig4cloud/pig/gateway/config/GatewayConfiguration.java index 094fcc951..11ad9ee97 100644 --- a/pig-gateway/src/main/java/com/pig4cloud/pig/gateway/config/GatewayConfiguration.java +++ b/pig-gateway/src/main/java/com/pig4cloud/pig/gateway/config/GatewayConfiguration.java @@ -21,59 +21,62 @@ @EnableConfigurationProperties(GatewayConfigProperties.class) public class GatewayConfiguration { - /** - * 创建密码解码器过滤器 - * @param modifyRequestBodyGatewayFilterFactory 修改请求体网关过滤器工厂 - * @param configProperties 配置属性 - * @return 密码解码器过滤器 - */ - @Bean - public PasswordDecoderFilter passwordDecoderFilter( - ModifyRequestBodyGatewayFilterFactory modifyRequestBodyGatewayFilterFactory, - GatewayConfigProperties configProperties) { - return new PasswordDecoderFilter(modifyRequestBodyGatewayFilterFactory, configProperties); - } + /** + * 创建密码解码器过滤器 + * + * @param modifyRequestBodyGatewayFilterFactory 修改请求体网关过滤器工厂 + * @param configProperties 配置属性 + * @return 密码解码器过滤器 + */ + @Bean + public PasswordDecoderFilter passwordDecoderFilter( + ModifyRequestBodyGatewayFilterFactory modifyRequestBodyGatewayFilterFactory, + GatewayConfigProperties configProperties) { + return new PasswordDecoderFilter(modifyRequestBodyGatewayFilterFactory, configProperties); + } - /** - * 创建PigRequest全局过滤器 - * @return PigRequest全局过滤器 - */ - @Bean - public PigRequestGlobalFilter pigRequestGlobalFilter() { - return new PigRequestGlobalFilter(); - } + /** + * 创建PigRequest全局过滤器 + * + * @return PigRequest全局过滤器 + */ + @Bean + public PigRequestGlobalFilter pigRequestGlobalFilter() { + return new PigRequestGlobalFilter(); + } - /** - * 创建验证码网关过滤器 - * @param configProperties 配置属性 - * @param objectMapper 对象映射器 - * @param redisTemplate Redis模板 - * @return 验证码网关过滤器 - */ - @Bean - public ValidateCodeGatewayFilter validateCodeGatewayFilter(GatewayConfigProperties configProperties, - ObjectMapper objectMapper, RedisTemplate redisTemplate) { - return new ValidateCodeGatewayFilter(configProperties, objectMapper, redisTemplate); - } + /** + * 创建验证码网关过滤器 + * + * @param configProperties 配置属性 + * @param redisTemplate Redis模板 + * @return 验证码网关过滤器 + */ + @Bean + public ValidateCodeGatewayFilter validateCodeGatewayFilter(GatewayConfigProperties configProperties, RedisTemplate redisTemplate) { + return new ValidateCodeGatewayFilter(configProperties, redisTemplate); + } - /** - * 创建全局异常处理程序 - * @param objectMapper 对象映射器 - * @return 全局异常处理程序 - */ - @Bean - public GlobalExceptionHandler globalExceptionHandler(ObjectMapper objectMapper) { - return new GlobalExceptionHandler(objectMapper); - } + /** + * 创建全局异常处理程序 + * + * @param objectMapper 对象映射器 + * @return 全局异常处理程序 + */ + @Bean + public GlobalExceptionHandler globalExceptionHandler(ObjectMapper objectMapper) { + return new GlobalExceptionHandler(objectMapper); + } - /** - * 创建图片验证码处理器 - * @param redisTemplate Redis模板 - * @return 图片验证码处理器 - */ - @Bean - public ImageCodeHandler imageCodeHandler(RedisTemplate redisTemplate) { - return new ImageCodeHandler(redisTemplate); - } + /** + * 创建图片验证码处理器 + * + * @param redisTemplate Redis模板 + * @return 图片验证码处理器 + */ + @Bean + public ImageCodeHandler imageCodeHandler(RedisTemplate redisTemplate) { + return new ImageCodeHandler(redisTemplate); + } } diff --git a/pig-gateway/src/main/java/com/pig4cloud/pig/gateway/filter/ValidateCodeGatewayFilter.java b/pig-gateway/src/main/java/com/pig4cloud/pig/gateway/filter/ValidateCodeGatewayFilter.java index 20c1943b9..148135b82 100644 --- a/pig-gateway/src/main/java/com/pig4cloud/pig/gateway/filter/ValidateCodeGatewayFilter.java +++ b/pig-gateway/src/main/java/com/pig4cloud/pig/gateway/filter/ValidateCodeGatewayFilter.java @@ -54,8 +54,6 @@ public class ValidateCodeGatewayFilter extends AbstractGatewayFilterFactory redisTemplate; /** @@ -89,7 +87,7 @@ public GatewayFilter apply(Object config) { CharsetUtil.CHARSET_UTF_8); // 刷新请求跳过,直接向下执行 if (StrUtil.equals(SecurityConstants.REFRESH_TOKEN, requestBodyMap.get("grant_type"))) { - return chain.filter(exchange); + return chain.filter(exchange.mutate().request(serverHttpRequest).build()); } // 根据 randomStr 参数判断验证码是否正常