【发布时间】:2019-07-22 02:53:52
【问题描述】:
我们在 Spring Boot 2 应用程序中使用基于令牌的身份验证(使用 Spring Security)。现在我正在向它介绍 Spring Boot Actuator。我想将/health 端点配置为在没有任何权限的情况下可见,但仅在获得授权时才显示健康检查详细信息。
我找到了 management.endpoint.health.show-details=when_authorized 属性,这应该会有所帮助,但现在我正在与 Spring Security 配置作斗争以让每个人都能看到:
{
"status": "UP"
}
在/actuator/health 下,而使用令牌授权的用户应该看到:
{
"status": "UP",
"details": { ... }
}
您是否遇到过类似的问题?你是怎么处理的?
【问题讨论】:
-
当您访问此端点时,无论是否经过身份验证,应用程序的行为如何?
-
现在,当设置了参数
management.endpoint.health.show-details=when_authorized并且我正在为此端点打开身份验证时,我会看到详细信息。但未经身份验证我无法进入。当我关闭端点的身份验证并设置when_authorized时,我看不到详细信息。所以参数工作正常。但我无法弄清楚如何将/actuator/health端点设置为在有和没有身份验证的情况下都可用...... -
@PiotrPradzynski 你是怎么解决这个问题的?我也卡在了同一个地方!
标签: spring spring-boot spring-security spring-boot-actuator