您好,我正在使用sprinb-boot2中的致动器,具有以下属性
management.endpoints.enabled-by-default=false
management.endpoint.health.enabled=true我的目标是禁用除健康之外的所有端点。通过此配置,我禁用了除健康和获取以下端点以外的所有端点,现在使用"health", "health-component", "health-component-instance"。是否也可以禁用"health-component", "health-component-instance"?又是如何做到的?
发布于 2019-05-08 23:27:07
健康组件端点是作为现有HealthEndpoint的扩展在Spring Boot 2.2.0.M2中引入的。
没有仅禁用/health-component和/health-component-instance的配置选项,要么禁用整个health端点,要么不禁用。
发布于 2019-05-09 00:06:32
对于SpringBoot 2.1.3,您可以在application.yml中使用以下内容:
#ENDPOINTS:
management:
endpoints:
web:
exposure:
include:
- 'health'
- 'info'它将使执行器中仅有两个列出的端点可用。
发布于 2019-05-09 00:02:19
在pom.xml中添加
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>添加一个配置类:
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/actuator/health/*").authenticated()
.antMatchers("/**").permitAll();
}
}https://stackoverflow.com/questions/56043811
复制相似问题