diff --git a/whatsmars-spring-boot-samples/whatsmars-boot-sample-actuator/pom.xml b/whatsmars-spring-boot-samples/whatsmars-boot-sample-actuator/pom.xml
index 917d28420652ad5564f378167ce06661b884bbae..fb8fe35c4ec04fca3448adb9fa1118a5468bf2d8 100644
--- a/whatsmars-spring-boot-samples/whatsmars-boot-sample-actuator/pom.xml
+++ b/whatsmars-spring-boot-samples/whatsmars-boot-sample-actuator/pom.xml
@@ -18,6 +18,7 @@
org.springframework.boot
spring-boot-starter-web
+ true
org.springframework.boot
diff --git a/whatsmars-spring-boot-samples/whatsmars-boot-sample-actuator/src/main/java/org/hongxi/whatsmars/boot/sample/actuator/ActuatorAutoConfiguration.java b/whatsmars-spring-boot-samples/whatsmars-boot-sample-actuator/src/main/java/org/hongxi/whatsmars/boot/sample/actuator/ActuatorAutoConfiguration.java
index cb6691452057a6b2988cbb394aa5c68eda57c1b7..6c045c88cbb3185fa70bf4a077592d8685d50459 100644
--- a/whatsmars-spring-boot-samples/whatsmars-boot-sample-actuator/src/main/java/org/hongxi/whatsmars/boot/sample/actuator/ActuatorAutoConfiguration.java
+++ b/whatsmars-spring-boot-samples/whatsmars-boot-sample-actuator/src/main/java/org/hongxi/whatsmars/boot/sample/actuator/ActuatorAutoConfiguration.java
@@ -1,5 +1,6 @@
package org.hongxi.whatsmars.boot.sample.actuator;
+import org.hongxi.whatsmars.boot.sample.actuator.filter.ActuatorFilter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -10,15 +11,21 @@ import org.springframework.security.config.annotation.web.WebSecurityConfigurer;
* Created by shenhongxi on 2020/7/17.
*/
@Configuration
-@ConditionalOnWebApplication
public class ActuatorAutoConfiguration {
@Order(99)
@Bean
+ @ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET)
public WebSecurityConfigurer standardWebSecurityConfigurer() {
return new StandardWebSecurityConfigurer();
}
+ @Bean
+ @ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET)
+ public ActuatorFilter actuatorFilter() {
+ return new ActuatorFilter();
+ }
+
@Bean
public ActuatorReporter actuatorReporter() {
return new ActuatorReporter();
diff --git a/whatsmars-spring-boot-samples/whatsmars-boot-sample-actuator/src/main/java/org/hongxi/whatsmars/boot/sample/actuator/filter/ActuatorFilter.java b/whatsmars-spring-boot-samples/whatsmars-boot-sample-actuator/src/main/java/org/hongxi/whatsmars/boot/sample/actuator/filter/ActuatorFilter.java
new file mode 100644
index 0000000000000000000000000000000000000000..8f4c4a023d2134e6afee5cb18f2be2f9f12a7f0f
--- /dev/null
+++ b/whatsmars-spring-boot-samples/whatsmars-boot-sample-actuator/src/main/java/org/hongxi/whatsmars/boot/sample/actuator/filter/ActuatorFilter.java
@@ -0,0 +1,24 @@
+package org.hongxi.whatsmars.boot.sample.actuator.filter;
+
+import org.springframework.http.HttpStatus;
+import org.springframework.web.filter.OncePerRequestFilter;
+
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+/**
+ * Created by shenhongxi on 2020/8/13.
+ */
+public class ActuatorFilter extends OncePerRequestFilter {
+ @Override
+ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
+// if (request.getServletPath().startsWith("/actuator")) {
+// response.sendError(HttpStatus.FORBIDDEN.value());
+// } else {
+// filterChain.doFilter(request, response);
+// }
+ }
+}