mirror of
https://gitee.com/log4j/pig.git
synced 2024-12-23 13:03:42 +08:00
!87 sentinel 接入 nacos ,支持 spring boot admin 监控
Merge pull request !87 from lbw/dev
This commit is contained in:
commit
8740f06293
@ -13,6 +13,11 @@
|
|||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<!--注册中心客户端-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba.csp</groupId>
|
<groupId>com.alibaba.csp</groupId>
|
||||||
<artifactId>sentinel-core</artifactId>
|
<artifactId>sentinel-core</artifactId>
|
||||||
|
@ -20,16 +20,11 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.util.AntPathMatcher;
|
||||||
|
|
||||||
import javax.servlet.Filter;
|
import javax.servlet.*;
|
||||||
import javax.servlet.FilterChain;
|
|
||||||
import javax.servlet.FilterConfig;
|
|
||||||
import javax.servlet.ServletException;
|
|
||||||
import javax.servlet.ServletRequest;
|
|
||||||
import javax.servlet.ServletResponse;
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -59,6 +54,8 @@ public class LoginAuthenticationFilter implements Filter {
|
|||||||
|
|
||||||
private static final String URL_SUFFIX_DOT = ".";
|
private static final String URL_SUFFIX_DOT = ".";
|
||||||
|
|
||||||
|
private static final AntPathMatcher PATH_MATCHER = new AntPathMatcher();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Some urls which needn't auth, such as /auth/login, /registry/machine and so on.
|
* Some urls which needn't auth, such as /auth/login, /registry/machine and so on.
|
||||||
*/
|
*/
|
||||||
@ -90,6 +87,10 @@ public class LoginAuthenticationFilter implements Filter {
|
|||||||
String servletPath = httpRequest.getServletPath();
|
String servletPath = httpRequest.getServletPath();
|
||||||
|
|
||||||
// Exclude the urls which needn't auth
|
// Exclude the urls which needn't auth
|
||||||
|
if (authFilterExcludeUrls.stream().anyMatch(s -> PATH_MATCHER.match(s, servletPath))) {
|
||||||
|
chain.doFilter(request, response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (authFilterExcludeUrls.contains(servletPath)) {
|
if (authFilterExcludeUrls.contains(servletPath)) {
|
||||||
chain.doFilter(request, response);
|
chain.doFilter(request, response);
|
||||||
return;
|
return;
|
||||||
|
@ -4,6 +4,14 @@ server:
|
|||||||
encoding:
|
encoding:
|
||||||
force: true
|
force: true
|
||||||
|
|
||||||
|
management:
|
||||||
|
endpoints:
|
||||||
|
web:
|
||||||
|
exposure:
|
||||||
|
include: '*'
|
||||||
|
endpoint:
|
||||||
|
health:
|
||||||
|
show-details: ALWAYS
|
||||||
logging:
|
logging:
|
||||||
level:
|
level:
|
||||||
org:
|
org:
|
||||||
@ -18,7 +26,7 @@ auth:
|
|||||||
username: sentinel
|
username: sentinel
|
||||||
password: sentinel
|
password: sentinel
|
||||||
filter:
|
filter:
|
||||||
exclude-urls: /,/auth/login,/auth/logout,/registry/machine,/version
|
exclude-urls: /,/auth/login,/auth/logout,/registry/machine,/version,/actuator/**,/details
|
||||||
exclude-url-suffixes: htm,html,js,css,map,ico,ttf,woff,png
|
exclude-url-suffixes: htm,html,js,css,map,ico,ttf,woff,png
|
||||||
|
|
||||||
sentinel:
|
sentinel:
|
||||||
|
@ -0,0 +1,15 @@
|
|||||||
|
server:
|
||||||
|
port: 5020
|
||||||
|
servlet:
|
||||||
|
encoding:
|
||||||
|
force: true
|
||||||
|
|
||||||
|
spring:
|
||||||
|
application:
|
||||||
|
name: @artifactId@
|
||||||
|
cloud:
|
||||||
|
nacos:
|
||||||
|
discovery:
|
||||||
|
server-addr: ${NACOS_HOST:pigx-register}:${NACOS_PORT:8848}
|
||||||
|
profiles:
|
||||||
|
active: @profiles.active@
|
Loading…
Reference in New Issue
Block a user