清理端点应允许通过curl命令

问题描述 投票:0回答:1

我已在我的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个回答
0
投票

有效。我删除了@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();
                }

感谢所有人。

© www.soinside.com 2019 - 2024. All rights reserved.