| | |
| | | import com.ruoyi.common.core.utils.ServletUtils; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.common.core.utils.html.EscapeUtil; |
| | | import com.ruoyi.gateway.config.properties.IgnoreWhiteProperties; |
| | | import com.ruoyi.gateway.config.properties.XssProperties; |
| | | import io.netty.buffer.ByteBufAllocator; |
| | | import org.apache.commons.codec.binary.Base64; |
| | |
| | | */ |
| | | @Component |
| | | public class RequestParamGlobalFilter implements GlobalFilter, Ordered { |
| | | |
| | | @Autowired |
| | | private IgnoreWhiteProperties ignoreWhite; |
| | | |
| | | |
| | | @Override |
| | | public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) { |
| | | ServerHttpRequest request = exchange.getRequest(); |
| | | ServerHttpRequest.Builder mutate = request.mutate(); |
| | | HttpMethod method = request.getMethod(); |
| | | if(method != HttpMethod.POST){ |
| | | return chain.filter(exchange.mutate().request(mutate.build()).build()); |
| | | } |
| | | // 跳过不需要验证的路径 |
| | | String url = request.getURI().getPath(); |
| | | if (StringUtils.matches(url, ignoreWhite.getWhites())) { |
| | | return chain.filter(exchange); |
| | | } |
| | | ServerHttpRequestDecorator httpRequestDecorator = requestDecorator(exchange); |
| | | return chain.filter(exchange.mutate().request(httpRequestDecorator).build()); |
| | | } |