diff --git a/pig-visual/pig-sentinel-dashboard/pom.xml b/pig-visual/pig-sentinel-dashboard/pom.xml index 82d43a3f..308c7225 100755 --- a/pig-visual/pig-sentinel-dashboard/pom.xml +++ b/pig-visual/pig-sentinel-dashboard/pom.xml @@ -13,6 +13,11 @@ jar + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + com.alibaba.csp sentinel-core diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/LoginAuthenticationFilter.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/LoginAuthenticationFilter.java index aab3a511..1b63873d 100644 --- a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/LoginAuthenticationFilter.java +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/LoginAuthenticationFilter.java @@ -20,16 +20,11 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Component; +import org.springframework.util.AntPathMatcher; -import javax.servlet.Filter; -import javax.servlet.FilterChain; -import javax.servlet.FilterConfig; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; +import javax.servlet.*; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; - import java.io.IOException; import java.util.List; @@ -59,6 +54,8 @@ public class LoginAuthenticationFilter implements Filter { 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. */ @@ -90,6 +87,10 @@ public class LoginAuthenticationFilter implements Filter { String servletPath = httpRequest.getServletPath(); // 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)) { chain.doFilter(request, response); return; diff --git a/pig-visual/pig-sentinel-dashboard/src/main/resources/application.yml b/pig-visual/pig-sentinel-dashboard/src/main/resources/application.yml index ec08852d..c8bf5dc6 100755 --- a/pig-visual/pig-sentinel-dashboard/src/main/resources/application.yml +++ b/pig-visual/pig-sentinel-dashboard/src/main/resources/application.yml @@ -4,6 +4,14 @@ server: encoding: force: true +management: + endpoints: + web: + exposure: + include: '*' + endpoint: + health: + show-details: ALWAYS logging: level: org: @@ -18,7 +26,7 @@ auth: username: sentinel password: sentinel 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 sentinel: diff --git a/pig-visual/pig-sentinel-dashboard/src/main/resources/bootstrap.yml b/pig-visual/pig-sentinel-dashboard/src/main/resources/bootstrap.yml new file mode 100644 index 00000000..0e47b57b --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/resources/bootstrap.yml @@ -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@ \ No newline at end of file