remove 重大改动 删除sentinel所有相关功能(为什么删除 查看文档详细说明 https://plus-doc.dromara.org/#/questions/sentinel_404)
parent
2c93bdc5dd
commit
e0f68ef605
@ -1,12 +0,0 @@
|
|||||||
<component name="ProjectRunConfigurationManager">
|
|
||||||
<configuration default="false" name="ruoyi-sentinel-dashboard" type="docker-deploy" factoryName="dockerfile" server-name="Docker">
|
|
||||||
<deployment type="dockerfile">
|
|
||||||
<settings>
|
|
||||||
<option name="imageTag" value="ruoyi/ruoyi-sentinel-dashboard:2.4.1" />
|
|
||||||
<option name="buildOnly" value="true" />
|
|
||||||
<option name="sourceFilePath" value="ruoyi-visual/ruoyi-sentinel-dashboard/Dockerfile" />
|
|
||||||
</settings>
|
|
||||||
</deployment>
|
|
||||||
<method v="2" />
|
|
||||||
</configuration>
|
|
||||||
</component>
|
|
||||||
@ -1,51 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<parent>
|
|
||||||
<groupId>org.dromara</groupId>
|
|
||||||
<artifactId>ruoyi-common</artifactId>
|
|
||||||
<version>${revision}</version>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<artifactId>ruoyi-common-sentinel</artifactId>
|
|
||||||
|
|
||||||
<description>
|
|
||||||
ruoyi-common-sentinel 限流模块
|
|
||||||
</description>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<!-- SpringCloud Alibaba Sentinel -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba.cloud</groupId>
|
|
||||||
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Sentinel Datasource Nacos -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba.csp</groupId>
|
|
||||||
<artifactId>sentinel-datasource-nacos</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba.csp</groupId>
|
|
||||||
<artifactId>sentinel-apache-dubbo3-adapter</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.fasterxml.jackson.dataformat</groupId>
|
|
||||||
<artifactId>jackson-dataformat-xml</artifactId>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.dromara</groupId>
|
|
||||||
<artifactId>ruoyi-common-core</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-autoconfigure</artifactId>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
</project>
|
|
||||||
@ -1,52 +0,0 @@
|
|||||||
package org.dromara.common.sentinel.config;
|
|
||||||
|
|
||||||
import com.alibaba.cloud.commons.lang.StringUtils;
|
|
||||||
import com.alibaba.cloud.sentinel.SentinelProperties;
|
|
||||||
import com.alibaba.cloud.sentinel.custom.SentinelAutoConfiguration;
|
|
||||||
import com.alibaba.csp.sentinel.init.InitExecutor;
|
|
||||||
import com.alibaba.csp.sentinel.transport.config.TransportConfig;
|
|
||||||
import org.dromara.common.core.utils.StreamUtils;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
|
||||||
import org.springframework.cloud.client.ServiceInstance;
|
|
||||||
import org.springframework.cloud.client.discovery.DiscoveryClient;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Lion Li
|
|
||||||
*/
|
|
||||||
@AutoConfiguration(before = SentinelAutoConfiguration.class)
|
|
||||||
@EnableConfigurationProperties({SentinelProperties.class, SentinelCustomProperties.class})
|
|
||||||
public class SentinelCustomAutoConfiguration {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private SentinelProperties properties;
|
|
||||||
@Autowired
|
|
||||||
private SentinelCustomProperties customProperties;
|
|
||||||
@Autowired
|
|
||||||
private DiscoveryClient discoveryClient;
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public Object sentinelInit() {
|
|
||||||
if (StringUtils.isNotBlank(customProperties.getServerName())) {
|
|
||||||
List<ServiceInstance> instances = discoveryClient.getInstances(customProperties.getServerName());
|
|
||||||
String serverList = StreamUtils.join(instances, instance ->
|
|
||||||
String.format("http://%s:%s", instance.getHost(), instance.getPort()));
|
|
||||||
System.setProperty(TransportConfig.CONSOLE_SERVER, serverList);
|
|
||||||
} else {
|
|
||||||
if (StringUtils.isEmpty(System.getProperty(TransportConfig.CONSOLE_SERVER))
|
|
||||||
&& StringUtils.isNotBlank(properties.getTransport().getDashboard())) {
|
|
||||||
System.setProperty(TransportConfig.CONSOLE_SERVER,
|
|
||||||
properties.getTransport().getDashboard());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 手动初始化 sentinel
|
|
||||||
InitExecutor.doInit();
|
|
||||||
return new Object();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,17 +0,0 @@
|
|||||||
package org.dromara.common.sentinel.config;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* sentinel自定义配置类
|
|
||||||
*
|
|
||||||
* @author Lion Li
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@ConfigurationProperties(prefix = "spring.cloud.sentinel.transport")
|
|
||||||
public class SentinelCustomProperties {
|
|
||||||
|
|
||||||
private String serverName;
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1 +0,0 @@
|
|||||||
org.dromara.common.sentinel.config.SentinelCustomAutoConfiguration
|
|
||||||
@ -1,96 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 1999-2019 Alibaba Group Holding Ltd.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package com.alibaba.csp.sentinel.adapter.gateway.sc.callback;
|
|
||||||
|
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.http.InvalidMediaTypeException;
|
|
||||||
import org.springframework.http.MediaType;
|
|
||||||
import org.springframework.util.MimeTypeUtils;
|
|
||||||
import org.springframework.web.reactive.function.server.ServerResponse;
|
|
||||||
import org.springframework.web.server.ServerWebExchange;
|
|
||||||
import reactor.core.publisher.Mono;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static org.springframework.web.reactive.function.BodyInserters.fromObject;
|
|
||||||
|
|
||||||
// https://github.com/alibaba/Sentinel/issues/3298
|
|
||||||
// 临时解决 sentinel 限流插件 jdk17 报错问题
|
|
||||||
/**
|
|
||||||
* The default implementation of {@link BlockRequestHandler}.
|
|
||||||
* Compatible with Spring WebFlux and Spring Cloud Gateway.
|
|
||||||
*
|
|
||||||
* @author Eric Zhao
|
|
||||||
*/
|
|
||||||
public class DefaultBlockRequestHandler implements BlockRequestHandler {
|
|
||||||
|
|
||||||
private static final String DEFAULT_BLOCK_MSG_PREFIX = "Blocked by Sentinel: ";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Mono<ServerResponse> handleRequest(ServerWebExchange exchange, Throwable ex) {
|
|
||||||
if (acceptsHtml(exchange)) {
|
|
||||||
return htmlErrorResponse(ex);
|
|
||||||
}
|
|
||||||
// JSON result by default.
|
|
||||||
return ServerResponse.status(HttpStatus.TOO_MANY_REQUESTS)
|
|
||||||
.contentType(MediaType.APPLICATION_JSON_UTF8)
|
|
||||||
.body(fromObject(buildErrorResult(ex)));
|
|
||||||
}
|
|
||||||
|
|
||||||
private Mono<ServerResponse> htmlErrorResponse(Throwable ex) {
|
|
||||||
return ServerResponse.status(HttpStatus.TOO_MANY_REQUESTS)
|
|
||||||
.contentType(MediaType.TEXT_PLAIN)
|
|
||||||
.syncBody(DEFAULT_BLOCK_MSG_PREFIX + ex.getClass().getSimpleName());
|
|
||||||
}
|
|
||||||
|
|
||||||
private ErrorResult buildErrorResult(Throwable ex) {
|
|
||||||
return new ErrorResult(HttpStatus.TOO_MANY_REQUESTS.value(),
|
|
||||||
DEFAULT_BLOCK_MSG_PREFIX + ex.getClass().getSimpleName());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reference from {@code DefaultErrorWebExceptionHandler} of Spring Boot.
|
|
||||||
*/
|
|
||||||
private boolean acceptsHtml(ServerWebExchange exchange) {
|
|
||||||
try {
|
|
||||||
List<MediaType> acceptedMediaTypes = exchange.getRequest().getHeaders().getAccept();
|
|
||||||
acceptedMediaTypes.remove(MediaType.ALL);
|
|
||||||
MimeTypeUtils. sortBySpecificity(acceptedMediaTypes);
|
|
||||||
return acceptedMediaTypes.stream()
|
|
||||||
.anyMatch(MediaType.TEXT_HTML::isCompatibleWith);
|
|
||||||
} catch (InvalidMediaTypeException ex) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class ErrorResult {
|
|
||||||
private final int code;
|
|
||||||
private final String message;
|
|
||||||
|
|
||||||
ErrorResult(int code, String message) {
|
|
||||||
this.code = code;
|
|
||||||
this.message = message;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getCode() {
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMessage() {
|
|
||||||
return message;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,36 +0,0 @@
|
|||||||
package org.dromara.gateway.handler;
|
|
||||||
|
|
||||||
import com.alibaba.csp.sentinel.adapter.gateway.sc.callback.GatewayCallbackManager;
|
|
||||||
import com.alibaba.csp.sentinel.slots.block.BlockException;
|
|
||||||
import org.dromara.gateway.utils.WebFluxUtils;
|
|
||||||
import org.springframework.web.reactive.function.server.ServerResponse;
|
|
||||||
import org.springframework.web.server.ServerWebExchange;
|
|
||||||
import org.springframework.web.server.WebExceptionHandler;
|
|
||||||
import reactor.core.publisher.Mono;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 自定义限流异常处理
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
public class SentinelFallbackHandler implements WebExceptionHandler {
|
|
||||||
private Mono<Void> writeResponse(ServerResponse response, ServerWebExchange exchange) {
|
|
||||||
return WebFluxUtils.webFluxResponseWriter(exchange.getResponse(), "请求超过最大数,请稍候再试");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Mono<Void> handle(ServerWebExchange exchange, Throwable ex) {
|
|
||||||
ex.printStackTrace();
|
|
||||||
if (exchange.getResponse().isCommitted()) {
|
|
||||||
return Mono.error(ex);
|
|
||||||
}
|
|
||||||
if (!BlockException.isBlockException(ex)) {
|
|
||||||
return Mono.error(ex);
|
|
||||||
}
|
|
||||||
return handleBlockedRequest(exchange, ex).flatMap(response -> writeResponse(response, exchange));
|
|
||||||
}
|
|
||||||
|
|
||||||
private Mono<ServerResponse> handleBlockedRequest(ServerWebExchange exchange, Throwable throwable) {
|
|
||||||
return GatewayCallbackManager.getBlockHandler().handleRequest(exchange, throwable);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,24 +0,0 @@
|
|||||||
# 贝尔实验室 Spring 官方推荐镜像 JDK下载地址 https://bell-sw.com/pages/downloads/
|
|
||||||
FROM bellsoft/liberica-openjdk-rocky:17.0.15-cds
|
|
||||||
#FROM bellsoft/liberica-openjdk-rocky:21.0.7-cds
|
|
||||||
#FROM findepi/graalvm:java17-native
|
|
||||||
|
|
||||||
LABEL maintainer="Lion Li"
|
|
||||||
|
|
||||||
RUN mkdir -p /ruoyi/sentinel-dashboard/logs \
|
|
||||||
/ruoyi/skywalking/agent
|
|
||||||
|
|
||||||
WORKDIR /ruoyi/sentinel-dashboard
|
|
||||||
|
|
||||||
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8 JAVA_OPTS=""
|
|
||||||
|
|
||||||
EXPOSE 8718
|
|
||||||
|
|
||||||
ADD ./target/ruoyi-sentinel-dashboard.jar ./app.jar
|
|
||||||
|
|
||||||
SHELL ["/bin/bash", "-c"]
|
|
||||||
|
|
||||||
ENTRYPOINT java -Djava.security.egd=file:/dev/./urandom \
|
|
||||||
#-Dskywalking.agent.service_name=ruoyi-sentinel-dashboard \
|
|
||||||
#-javaagent:/ruoyi/skywalking/agent/skywalking-agent.jar \
|
|
||||||
${JAVA_OPTS} -jar app.jar
|
|
||||||
@ -1,186 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<parent>
|
|
||||||
<groupId>org.dromara</groupId>
|
|
||||||
<artifactId>ruoyi-visual</artifactId>
|
|
||||||
<version>${revision}</version>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<artifactId>ruoyi-sentinel-dashboard</artifactId>
|
|
||||||
<packaging>jar</packaging>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<sentinel.version>1.8.8</sentinel.version>
|
|
||||||
<curator.version>4.0.1</curator.version>
|
|
||||||
<spring-boot.version>2.7.18</spring-boot.version>
|
|
||||||
<spring-cloud.version>2021.0.7</spring-cloud.version>
|
|
||||||
<spring-cloud-alibaba.version>2021.0.4.0</spring-cloud-alibaba.version>
|
|
||||||
<logstash-logback-encoder.version>7.2</logstash-logback-encoder.version>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<dependencyManagement>
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-dependencies</artifactId>
|
|
||||||
<version>${spring-boot.version}</version>
|
|
||||||
<type>pom</type>
|
|
||||||
<scope>import</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.cloud</groupId>
|
|
||||||
<artifactId>spring-cloud-dependencies</artifactId>
|
|
||||||
<version>${spring-cloud.version}</version>
|
|
||||||
<type>pom</type>
|
|
||||||
<scope>import</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba.cloud</groupId>
|
|
||||||
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
|
|
||||||
<version>${spring-cloud-alibaba.version}</version>
|
|
||||||
<type>pom</type>
|
|
||||||
<scope>import</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</dependencyManagement>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.dromara</groupId>
|
|
||||||
<artifactId>ruoyi-common-nacos</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba.csp</groupId>
|
|
||||||
<artifactId>sentinel-dashboard</artifactId>
|
|
||||||
<version>${sentinel.version}</version>
|
|
||||||
<scope>system</scope>
|
|
||||||
<systemPath>${project.basedir}/src/main/resources/lib/sentinel-dashboard-${sentinel.version}.jar</systemPath>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba.csp</groupId>
|
|
||||||
<artifactId>sentinel-core</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba.csp</groupId>
|
|
||||||
<artifactId>sentinel-web-servlet</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba.csp</groupId>
|
|
||||||
<artifactId>sentinel-transport-simple-http</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba.csp</groupId>
|
|
||||||
<artifactId>sentinel-parameter-flow-control</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba.csp</groupId>
|
|
||||||
<artifactId>sentinel-api-gateway-adapter-common</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- SpringBoot Web容器 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<artifactId>*</artifactId>
|
|
||||||
<groupId>org.apache.logging.log4j</groupId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- 覆盖 tomcat version 避免CVE-2024-24549-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.tomcat.embed</groupId>
|
|
||||||
<artifactId>tomcat-embed-websocket</artifactId>
|
|
||||||
<version>9.0.105</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.tomcat.embed</groupId>
|
|
||||||
<artifactId>tomcat-embed-core</artifactId>
|
|
||||||
<version>9.0.105</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.tomcat.embed</groupId>
|
|
||||||
<artifactId>tomcat-embed-el</artifactId>
|
|
||||||
<version>9.0.105</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- starter-actuator -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>commons-lang</groupId>
|
|
||||||
<artifactId>commons-lang</artifactId>
|
|
||||||
<version>2.6</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.httpcomponents</groupId>
|
|
||||||
<artifactId>httpclient</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.httpcomponents</groupId>
|
|
||||||
<artifactId>httpcore</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.httpcomponents</groupId>
|
|
||||||
<artifactId>httpasyncclient</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.httpcomponents</groupId>
|
|
||||||
<artifactId>httpcore-nio</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba</groupId>
|
|
||||||
<artifactId>fastjson</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<!-- logback -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>ch.qos.logback</groupId>
|
|
||||||
<artifactId>logback-classic</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>ch.qos.logback</groupId>
|
|
||||||
<artifactId>logback-core</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<!-- logback appenders -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>net.logstash.logback</groupId>
|
|
||||||
<artifactId>logstash-logback-encoder</artifactId>
|
|
||||||
<version>${logstash-logback-encoder.version}</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<finalName>${project.artifactId}</finalName>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
|
||||||
<version>${spring-boot.version}</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<goals>
|
|
||||||
<goal>repackage</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
<configuration>
|
|
||||||
<!-- 作用:项目打成jar的同时将本地jar包也引入进去 -->
|
|
||||||
<includeSystemScope>true</includeSystemScope>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
</project>
|
|
||||||
@ -1,38 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 1999-2018 Alibaba Group Holding Ltd.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package com.alibaba.csp.sentinel.dashboard;
|
|
||||||
|
|
||||||
import com.alibaba.csp.sentinel.init.InitExecutor;
|
|
||||||
import org.springframework.boot.SpringApplication;
|
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sentinel dashboard application.
|
|
||||||
*
|
|
||||||
* @author Carpenter Lee
|
|
||||||
*/
|
|
||||||
@SpringBootApplication
|
|
||||||
public class DashboardApplication {
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
triggerSentinelInit();
|
|
||||||
SpringApplication.run(DashboardApplication.class, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void triggerSentinelInit() {
|
|
||||||
new Thread(() -> InitExecutor.doInit()).start();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,63 +0,0 @@
|
|||||||
package com.alibaba.csp.sentinel.dashboard.filter;
|
|
||||||
|
|
||||||
import javax.servlet.*;
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.util.Base64;
|
|
||||||
|
|
||||||
public class ActuatorAuthFilter implements Filter {
|
|
||||||
|
|
||||||
private final String username;
|
|
||||||
private final String password;
|
|
||||||
|
|
||||||
public ActuatorAuthFilter(String username, String password) {
|
|
||||||
this.username = username;
|
|
||||||
this.password = password;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
|
|
||||||
HttpServletRequest request = (HttpServletRequest) servletRequest;
|
|
||||||
HttpServletResponse response = (HttpServletResponse) servletResponse;
|
|
||||||
|
|
||||||
// 获取 Authorization 头
|
|
||||||
String authHeader = request.getHeader("Authorization");
|
|
||||||
|
|
||||||
if (authHeader == null || !authHeader.startsWith("Basic ")) {
|
|
||||||
// 如果没有提供 Authorization 或者格式不对,则返回 401
|
|
||||||
response.setHeader("WWW-Authenticate", "Basic realm=\"realm\"");
|
|
||||||
response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 解码 Base64 编码的用户名和密码
|
|
||||||
String base64Credentials = authHeader.substring("Basic ".length());
|
|
||||||
byte[] credDecoded = Base64.getDecoder().decode(base64Credentials);
|
|
||||||
String credentials = new String(credDecoded, StandardCharsets.UTF_8);
|
|
||||||
String[] split = credentials.split(":");
|
|
||||||
if (split.length != 2) {
|
|
||||||
response.setHeader("WWW-Authenticate", "Basic realm=\"realm\"");
|
|
||||||
response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 验证用户名和密码
|
|
||||||
if (!username.equals(split[0]) || !password.equals(split[1])) {
|
|
||||||
response.setHeader("WWW-Authenticate", "Basic realm=\"realm\"");
|
|
||||||
response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 如果认证成功,继续处理请求
|
|
||||||
filterChain.doFilter(request, response);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init(FilterConfig filterConfig) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void destroy() {
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,29 +0,0 @@
|
|||||||
package com.alibaba.csp.sentinel.dashboard.filter;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限安全配置
|
|
||||||
*
|
|
||||||
* @author Lion Li
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
public class SecurityConfig {
|
|
||||||
|
|
||||||
@Value("${spring.cloud.nacos.discovery.metadata.username}")
|
|
||||||
private String username;
|
|
||||||
@Value("${spring.cloud.nacos.discovery.metadata.userpassword}")
|
|
||||||
private String password;
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public FilterRegistrationBean<ActuatorAuthFilter> actuatorFilterRegistrationBean() {
|
|
||||||
FilterRegistrationBean<ActuatorAuthFilter> registrationBean = new FilterRegistrationBean<>();
|
|
||||||
registrationBean.setFilter(new ActuatorAuthFilter(username, password));
|
|
||||||
registrationBean.addUrlPatterns("/actuator", "/actuator/*");
|
|
||||||
return registrationBean;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1 +0,0 @@
|
|||||||
# 覆盖sentinel内置配置 不可删除
|
|
||||||
@ -1,37 +0,0 @@
|
|||||||
# Tomcat
|
|
||||||
server:
|
|
||||||
port: 8718
|
|
||||||
|
|
||||||
# Spring
|
|
||||||
spring:
|
|
||||||
application:
|
|
||||||
# 应用名称
|
|
||||||
name: ruoyi-sentinel-dashboard
|
|
||||||
profiles:
|
|
||||||
# 环境配置
|
|
||||||
active: @profiles.active@
|
|
||||||
|
|
||||||
sentinel:
|
|
||||||
dashboard:
|
|
||||||
version: @sentinel.version@
|
|
||||||
|
|
||||||
--- # nacos 配置
|
|
||||||
spring:
|
|
||||||
cloud:
|
|
||||||
nacos:
|
|
||||||
# nacos 服务地址
|
|
||||||
server-addr: @nacos.server@
|
|
||||||
username: @nacos.username@
|
|
||||||
password: @nacos.password@
|
|
||||||
discovery:
|
|
||||||
# 注册组
|
|
||||||
group: @nacos.discovery.group@
|
|
||||||
namespace: ${spring.profiles.active}
|
|
||||||
config:
|
|
||||||
# 配置组
|
|
||||||
group: @nacos.config.group@
|
|
||||||
namespace: ${spring.profiles.active}
|
|
||||||
config:
|
|
||||||
import:
|
|
||||||
- optional:nacos:application-common.yml
|
|
||||||
- optional:nacos:${spring.application.name}.yml
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
Spring Boot Version: ${spring-boot.version}
|
|
||||||
Spring Application Name: ${spring.application.name}
|
|
||||||
_ _ _ _ _ _ _
|
|
||||||
| | (_) | | | | | | | | | |
|
|
||||||
___ ___ _ __ | |_ _ _ __ ___| |______ __| | __ _ ___| |__ | |__ ___ __ _ _ __ __| |
|
|
||||||
/ __|/ _ \ '_ \| __| | '_ \ / _ \ |______/ _` |/ _` / __| '_ \| '_ \ / _ \ / _` | '__/ _` |
|
|
||||||
\__ \ __/ | | | |_| | | | | __/ | | (_| | (_| \__ \ | | | |_) | (_) | (_| | | | (_| |
|
|
||||||
|___/\___|_| |_|\__|_|_| |_|\___|_| \__,_|\__,_|___/_| |_|_.__/ \___/ \__,_|_| \__,_|
|
|
||||||
Binary file not shown.
@ -1,97 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
|
|
||||||
<included>
|
|
||||||
|
|
||||||
<property name="log.pattern" value="%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n"/>
|
|
||||||
|
|
||||||
<!-- 控制台输出 -->
|
|
||||||
<appender name="file_console" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
|
||||||
<file>${log.path}/console.log</file>
|
|
||||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
|
||||||
<!-- 日志文件名格式 -->
|
|
||||||
<fileNamePattern>${log.path}/console.%d{yyyy-MM-dd}.log</fileNamePattern>
|
|
||||||
<!-- 日志最大 1天 -->
|
|
||||||
<maxHistory>1</maxHistory>
|
|
||||||
</rollingPolicy>
|
|
||||||
<encoder>
|
|
||||||
<pattern>${log.pattern}</pattern>
|
|
||||||
<charset>utf-8</charset>
|
|
||||||
</encoder>
|
|
||||||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
|
||||||
<!-- 过滤的级别 -->
|
|
||||||
<level>INFO</level>
|
|
||||||
</filter>
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
<!-- 系统日志输出 -->
|
|
||||||
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
|
||||||
<file>${log.path}/info.log</file>
|
|
||||||
<!-- 循环政策:基于时间创建日志文件 -->
|
|
||||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
|
||||||
<!-- 日志文件名格式 -->
|
|
||||||
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
|
|
||||||
<!-- 日志最大的历史 60天 -->
|
|
||||||
<maxHistory>60</maxHistory>
|
|
||||||
</rollingPolicy>
|
|
||||||
<encoder>
|
|
||||||
<pattern>${log.pattern}</pattern>
|
|
||||||
</encoder>
|
|
||||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
|
||||||
<!-- 过滤的级别 -->
|
|
||||||
<level>INFO</level>
|
|
||||||
<!-- 匹配时的操作:接收(记录) -->
|
|
||||||
<onMatch>ACCEPT</onMatch>
|
|
||||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
|
||||||
<onMismatch>DENY</onMismatch>
|
|
||||||
</filter>
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
|
||||||
<file>${log.path}/error.log</file>
|
|
||||||
<!-- 循环政策:基于时间创建日志文件 -->
|
|
||||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
|
||||||
<!-- 日志文件名格式 -->
|
|
||||||
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
|
|
||||||
<!-- 日志最大的历史 60天 -->
|
|
||||||
<maxHistory>60</maxHistory>
|
|
||||||
</rollingPolicy>
|
|
||||||
<encoder>
|
|
||||||
<pattern>${log.pattern}</pattern>
|
|
||||||
</encoder>
|
|
||||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
|
||||||
<!-- 过滤的级别 -->
|
|
||||||
<level>ERROR</level>
|
|
||||||
<!-- 匹配时的操作:接收(记录) -->
|
|
||||||
<onMatch>ACCEPT</onMatch>
|
|
||||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
|
||||||
<onMismatch>DENY</onMismatch>
|
|
||||||
</filter>
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
<!-- info异步输出 -->
|
|
||||||
<appender name="async_info" class="ch.qos.logback.classic.AsyncAppender">
|
|
||||||
<!-- 不丢失日志.默认的,如果队列的80%已满,则会丢弃TRACT、DEBUG、INFO级别的日志 -->
|
|
||||||
<discardingThreshold>0</discardingThreshold>
|
|
||||||
<!-- 更改默认的队列的深度,该值会影响性能.默认值为256 -->
|
|
||||||
<queueSize>512</queueSize>
|
|
||||||
<!-- 添加附加的appender,最多只能添加一个 -->
|
|
||||||
<appender-ref ref="file_info"/>
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
<!-- error异步输出 -->
|
|
||||||
<appender name="async_error" class="ch.qos.logback.classic.AsyncAppender">
|
|
||||||
<!-- 不丢失日志.默认的,如果队列的80%已满,则会丢弃TRACT、DEBUG、INFO级别的日志 -->
|
|
||||||
<discardingThreshold>0</discardingThreshold>
|
|
||||||
<!-- 更改默认的队列的深度,该值会影响性能.默认值为256 -->
|
|
||||||
<queueSize>512</queueSize>
|
|
||||||
<!-- 添加附加的appender,最多只能添加一个 -->
|
|
||||||
<appender-ref ref="file_error"/>
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
<!--系统操作日志-->
|
|
||||||
<root level="info">
|
|
||||||
<appender-ref ref="async_info"/>
|
|
||||||
<appender-ref ref="async_error"/>
|
|
||||||
<appender-ref ref="file_console"/>
|
|
||||||
</root>
|
|
||||||
</included>
|
|
||||||
@ -1,28 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
|
||||||
<!-- 日志存放路径 -->
|
|
||||||
<property name="log.path" value="logs/${project.artifactId}"/>
|
|
||||||
<!-- 日志输出格式 -->
|
|
||||||
<property name="console.log.pattern"
|
|
||||||
value="%cyan(%d{yyyy-MM-dd HH:mm:ss}) %green([%thread]) %highlight(%-5level) %boldMagenta(%logger{36}%n) - %msg%n"/>
|
|
||||||
|
|
||||||
<!-- 控制台输出 -->
|
|
||||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
|
||||||
<encoder>
|
|
||||||
<pattern>${console.log.pattern}</pattern>
|
|
||||||
<charset>utf-8</charset>
|
|
||||||
</encoder>
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
<include resource="logback-common.xml" />
|
|
||||||
|
|
||||||
<include resource="logback-logstash.xml" />
|
|
||||||
|
|
||||||
<!-- 开启 skywalking 日志收集 -->
|
|
||||||
<include resource="logback-skylog.xml" />
|
|
||||||
|
|
||||||
<!--系统操作日志-->
|
|
||||||
<root level="info">
|
|
||||||
<appender-ref ref="console"/>
|
|
||||||
</root>
|
|
||||||
</configuration>
|
|
||||||
@ -1,27 +0,0 @@
|
|||||||
spring:
|
|
||||||
mvc:
|
|
||||||
pathmatch:
|
|
||||||
# 修复 sentinel 控制台未适配 springboot 2.6 新路由方式
|
|
||||||
matching-strategy: ANT_PATH_MATCHER
|
|
||||||
|
|
||||||
server:
|
|
||||||
servlet:
|
|
||||||
encoding:
|
|
||||||
force: true
|
|
||||||
charset: UTF-8
|
|
||||||
enabled: true
|
|
||||||
session:
|
|
||||||
cookie:
|
|
||||||
name: sentinel_dashboard_cookie
|
|
||||||
|
|
||||||
logging:
|
|
||||||
level:
|
|
||||||
org.springframework.web: INFO
|
|
||||||
|
|
||||||
auth:
|
|
||||||
enabled: true
|
|
||||||
filter:
|
|
||||||
exclude-urls: /,/auth/login,/auth/logout,/registry/machine,/version,/actuator,/actuator/**
|
|
||||||
exclude-url-suffixes: htm,html,js,css,map,ico,ttf,woff,png
|
|
||||||
username: sentinel
|
|
||||||
password: sentinel
|
|
||||||
@ -1,26 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"resource": "ruoyi-auth",
|
|
||||||
"count": 500,
|
|
||||||
"grade": 1,
|
|
||||||
"limitApp": "default",
|
|
||||||
"strategy": 0,
|
|
||||||
"controlBehavior": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"resource": "ruoyi-system",
|
|
||||||
"count": 1000,
|
|
||||||
"grade": 1,
|
|
||||||
"limitApp": "default",
|
|
||||||
"strategy": 0,
|
|
||||||
"controlBehavior": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"resource": "ruoyi-resource",
|
|
||||||
"count": 500,
|
|
||||||
"grade": 1,
|
|
||||||
"limitApp": "default",
|
|
||||||
"strategy": 0,
|
|
||||||
"controlBehavior": 0
|
|
||||||
}
|
|
||||||
]
|
|
||||||
Loading…
Reference in New Issue