【发布时间】:2019-11-12 07:17:38
【问题描述】:
目标:保护所有执行器端点,除了信息和健康,但在用户通过身份验证时显示详细信息。
我的 pom 只有spring-boot-starter-web、spring-boot-starter-security 和spring-boot-starter-web(Spring boot 版本:2.1.6.RELEASE),整个配置是
@Configuration
public class ActuatorSecurity extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.requestMatcher(EndpointRequest.toAnyEndpoint().excluding("info", "health"))
.authorizeRequests()
.anyRequest().authenticated()
.and()
.httpBasic();
}
}
和application.yml
management:
endpoints:
web:
exposure:
include: "*"
endpoint:
health:
show-details: "when-authorized"
这可以保护所有端点并提供未经身份验证的信息和健康访问权限。但是,当使用凭据访问运行状况时,它不会返回详细信息。在这种情况下,management.endpoint.health.show-details="when-authorized" 似乎被忽略了。
有人知道如何解决这个问题吗?
【问题讨论】:
-
.requestMatchers(EndpointRequest.to("health","info")).permitAll()应该可以工作
标签: spring-boot spring-security spring-boot-actuator