【问题标题】:Spring Boot Actuator - enable single endpointSpring Boot Actuator - 启用单个端点
【发布时间】:2016-04-01 21:14:54
【问题描述】:

两个版本的 Spring Boot Actuator(1.2.5 和 1.3.0)在 HealthMvcEndpoint 的 isUnrestricted() 方法( && 和 || )的实现上有所不同。我明白这是为了保留这些限制

http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#production-ready-health-access-restrictions

但是现在有什么解决方案可以只启用一个端点(例如健康),不受全部内容的限制,而不暴露所有其他端点? 禁用 management.security.enabled 只是让所有端点无需身份验证即可访问 (?) - 看起来它并没有对端点敏感。

【问题讨论】:

  • 您要禁用除一个端点之外的所有端点,还是要全部启用它们但允许不受限制地访问单个端点?
  • 我想知道是否有可能保留端点的原始行为并使它们中的一个在不受限制的访问中可用。我可以覆盖 HealthMvcEndpoint,但这不是重点。

标签: java spring spring-boot spring-boot-actuator


【解决方案1】:

我设法部分解决了这个问题,首先由endpoints.enabled = false 禁用所有端点并禁用它们的安全性management.security.enabled = false
并启用了我想要的没有安全性的东西——比如 Health 端点 endpoints.health.enabled = trueendpoints.health.sensitive = false

【讨论】:

    【解决方案2】:

    对于执行器 2,这些属性已更改

    禁用所有执行器端点使用

    management.endpoints.enabled-by-default=false
    

    要启用特定端点,请使用management.endpoint.<id>.enabled 属性。以下示例启用关闭端点:

    management.endpoint.shutdown.enabled=true
    

    官方文档

    https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-features.html

    【讨论】:

    • 另外我需要暴露端点,例如management.endpoints.web.exposure.include=shutdown.
    猜你喜欢
    • 2016-09-01
    • 1970-01-01
    • 2016-06-01
    • 2020-09-15
    • 2016-09-07
    • 2021-04-24
    • 2016-03-27
    • 2020-06-01
    • 1970-01-01
    相关资源
    最近更新 更多