【问题标题】:cleanup endpoint should be allow through curl command应该通过 curl 命令允许清理端点
【发布时间】:2019-09-30 20:39:16
【问题描述】:

我在我的 application.yml 文件中禁用了清理端点,并且也将 enableByDefault 属性标记为 false。我不应该通过 curl 命令访问它。 但仍然通过 curl 命令,我能够访问清理端点。这里有什么遗漏吗?

        http://localhost:9001/app/cleanup/1000

        management:
          security:
            enabled: false
          context-path: /app
          endpoints:
            web:
              base-path: /app
              exposure:
                include: health, loggers, cleanup
            enabled-by-default: false
          endpoint:
            cleanup:
              enabled: false




        @Component
        @Slf4j
        @Endpoint(id = "cleanup", enableByDefault = false)
        @RequiredArgsConstructor
        public class CleanuEndpoint {


            @RequestMapping(produces = {
                    ActuatorMediaType.V1_JSON,
                    MediaType.APPLICATION_JSON_VALUE})
            @ResponseBody
            @ReadOperation
            public Object updateId(@PathVariable Long Id) {
                log.info("updateId() - END= cleanUp={}, id={}",cleanUp, id);
                return delegate.invoke();
            }

        }

【问题讨论】:

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


    【解决方案1】:

    成功了。 我删除了@PathVariable 并使用了@Selector。 现在根据“management.web.exposure.include”值启用和禁用清理端点。

            URL:- http://localhost:9001/app/cleanup/1000
    
                @Component
                @Slf4j
                @Endpoint(id = "cleanup")
                @RequiredArgsConstructor
                public class CleanuEndpoint {
                    @ResponseBody
                    @ReadOperation
                    public Object updateId(@Selector Long Id) {
                        log.info("updateId() - END= cleanUp={}, id={}",cleanUp, id);
                        return delegate.invoke();
                    }
    

    谢谢大家。

    【讨论】:

      猜你喜欢
      • 2011-11-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-04
      • 2013-08-18
      • 2016-10-12
      • 1970-01-01
      相关资源
      最近更新 更多